floweaver
floweaver copied to clipboard
Note need to restart jupyter after installation in README
I have a pandas dataframe, and I'm trying to get a sankey diagram out of it.
Here's the excerpt of code, copied mostly from the quickstart tutorial.
from ipysankeywidget import SankeyWidget
from floweaver import *
import pandas as pd
flowDf = lostWonDf.sort_values(['LeadSource','WonCount'], ascending=[True,False]).groupby(['LeadSource','WonCount','Type'], sort=False).agg({
'AmountGBP':'sum'
}).reset_index()
flowDf.rename(columns={'LeadSource':'source','AmountGBP':'value','Type':'type'}, inplace=True)
flowDf['target'] = flowDf.WonCount.apply(lambda x: 'Won' if x == 1 else 'Lost')
flowDf.drop('WonCount', axis=1, inplace=True)
SankeyWidget(links=flowDf.to_dict('records'))
I get this error when I run the cell.
TypeError Traceback (most recent call last)
in () 13 #.unstack().reset_index().set_index('LeadSource') 14 ---> 15 SankeyWidget(links=flowDf.to_dict('records')) 16 17 size = dict(width=570, height=300) TypeError: wrap() got an unexpected keyword argument 'links'
It was an install error. After restarting jupyter, it worked fine.
Great, glad it's working now. If there's anything that was missing from the instructions that would have made it easier to get started then let us know.
The examples and tutorials are great. This particular issue hit me because I had to restart jupyter to get it working. Might be worth adding a note to restart it after installing the extension
Thanks for the feedback. If you'd like to, it'd be great if you want to add a note yourself! You can edit the README.md file and add something, probably just where it says "To get started, open the quickstart tutorial in Jupyter notebook and step through the notebook cells to produce the fruit example shown above.". Any questions let me know.
Reopening as an easy first contribution to the README. If anyone would like to get involved, this would be a great way to get started.
- Fork the repository as described in CONTRIBUTING.md
- Add some text to the README file as noted above. Something like "Note: you may have to restart jupyter after installing the extensions before they can be used in the notebook." You can do this on your own computer and commit & push using git, or do it on Github directly using the :pencil2: icon.
- Open a pull request as described in CONTRIBUTING.md
Any questions let us know by commenting below. :smiley:
@ricklupton I would love to tackle this :)
@eyaltrabelsi Welcome, please have a go! :)
Do ask If you have any questions.