I have the folowing dataframe in pandas. The date are two diffrent dates, in this case the 16th and 17th Time will go from 00:00 to 24:00 after that it will be the next day :-) And percentage will go from 100 to 0.
date time percentage
2018-08-16 00:00 36
2018-08-16 00:01 37
2018-08-16 00:01 38
2018-08-16 00:03 39
2018-08-16 00:03 40
2018-08-16 00:04 41
2018-08-16 00:05 42
2018-08-16 00:05 43
2018-08-16 00:06 44
2018-08-16 00:07 45
2018-08-16 00:07 46
2018-08-16 00:08 47
...
2018-08-17 07:24 95
2018-08-17 07:25 94
2018-08-17 07:25 94
2018-08-17 07:32 95
2018-08-17 07:43 96
2018-08-17 07:52 97
...
Now i would like to plot this dat in a line graph like this:
Tried something with:
df.set_index('date', inplace=True)
df.groupby('time')['percentage'].plot(legend=True)
plt.show()
But alway retrurn with a "TypeError: Empty 'DataFrame': no numeric data to plot"
Can somebody help me?
This should do:
df.percentage=df.percentage.astype(int)
for i in df.date.unique():
aux=df[df.date==i]
plt.plot(aux.time,aux.percentage)
plt.show()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.