python - Create PyGal graph from pandas dataframe -


i wanted try using pygal it's ability create svg data i'm going create printed pdf page merged html svg graph.

what want equivalent of pygal.plot(dataframe) i'm not seeing in docs.

i know can do:

df = pd.series(np.random.randn(5), index = ['a', 'b', 'c', 'd', 'e']) chart = pygal.line() index, row in df.iteritems():     chart.add(index,row) 

but seems wrong python point of view. should doing differently?

plus how if dataframe had multiple columns?

you using pygal api wrong way. labels should correspond index. also, should avoid iteritems when using pandas.

line_chart = pg.line() line_chart.x_labels = ['a', 'b', 'c', 'd', 'e'] line_chart.add('firefox', pd.series(np.random.randn(5))) line_chart.render_to_file('bchart.svg') 

hope helps.

edit: dataframe can use of series , add them 1 one

line_chart.add('series name', pd.series(np.random.randn(5))) 

call.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -