我有以下数据框,希望创建一个标题为日期的图表,时间在x轴上,μ摩尔在y轴上:
0 2019-06-11 17:21:35 13.5
1 2019-06-11 17:22:35 13.1
2 2019-06-11 17:23:35 13.0
3 2019-06-11 17:24:35 11.8
4 2019-06-11 17:25:35 11.8
... ... ... ...
394 2019-06-11 23:55:38 0.0
395 2019-06-11 23:56:38 0.0
396 2019-06-11 23:57:38 0.0
397 2019-06-11 23:58:38 0.0
398 2019-06-11 23:59:38 0.0
我已经写出了一些数据帧,这些数据帧分开了时间段,并计算了下午5点、6点等的平均测量值。例如:
seventeen = df.iloc[:39] # seventeen (for 5pm)
seventeen["\u03bcmoles"].mean()
six_pm = df.iloc[39:99] # six_pm (for 6pm)
six_pm["\u03bcmoles"].mean()
等等
我想画出一个图表,用这种代码使用这些测量值:
df.plot(x ='Timestamp', y='\u03bcmoles', kind = 'line')
datapoints = seventeen, six_pm, seven, twenty_hundred, twenty_one, twenty_two, twenty_three (so these are all the datapoints for which I calculate the averages)
plt.show()
有什么办法可以做到这一点吗
考虑按小时聚集与<强> ^ {CD1> } /强>而不是单独的小时平均值。
如果需要特定的小时数,请使用
.loc
在聚合数据上使用.isin
按小时过滤:要用随机数据演示:
相关问题 更多 >
编程相关推荐