I am trying to plot a multi line graph from pandas in python. I need three lines (positive, negative, neutral) and their number of occurrences during time. On the x-axis I would have the time, on the y- axis I would have the number of occurrences and I would have three lines in one graph. If there is no occurrence then it would be automatically zero (for example in th etable there is no occurrence for "negative" so in the graph the point would be zero). I am attaching the table that I would need to turn into graph.
d = datapandas.groupby(["date","classification"]).size()
The most left column is the number of occurrence of the classification during the date. I could not find any easy way to plot this kind of graph.
You have just to unstack
the classification
index and plot the graph:
d.unstack('classification').fillna(0).plot()
Note: you can avoid groupby
by using value_counts
:
d = datapandas.value_counts(['date', 'classification'])