The original dataframe,df I had was:
date name count
0 2017-08-07 ABC 12
1 2017-08-08 ABC 5
2 2017-08-08 TTT 6
3 2017-08-09 TAC 5
4 2017-08-09 ABC 10
Then the following code was used to transform to the new dataframe,df2 below:
df = pd.DataFrame({"date":["2017-08-07","2017-08-08","2017-08-08","2017-08-09","2017-08-09"],"name":["ABC","ABC","TTT","TAC","ABC"], "count": ["12","5","6","5","10"]})
df = df.pivot(index='date', columns='name', values='count').reset_index().fillna(0)
Now dataframe,df2 is transformed to:
date ABC TTT TAC
0 2017-08-07 12 0 0
1 2017-08-08 5 6 0
2 2017-08-09 10 0 5
Now I tried to plot the dataframe,df2
in order to show each day on the x -axis vs the values in the column names/day on y-axis:( ABC,TTT,TAC ) but I keep getting two straight lines.
Here is the code:
fig=pyplot.figure()
ax=fig.add_subplot(1,1,1)
ax.set_title('Plot')
ax.plot(df2)