我想首先将我的数据帧按“id”分组,然后按“Datetime”分组。然后根据“日期时间”绘制每个传感器的“温度”数据。谢谢
Sudo代码:
_, ax = plt.subplots()
df_ = plots.groupby(['moteid', "Datetime"])
for sensorID in df_moteid.unique():
plot df['temp'] against df['Datetime']
编辑:
我通过首先在read_csv中声明index_col='Datetime'
来绘制每个senosor数据,使其成为主索引,然后像这样绘制:
_, ax = plt.subplots()
for key, group in df.groupby('moteid'):
rgb = np.random.rand(3,)
group.plot.line(ax=ax, y='temp', color=[rgb], label=key)
plt.show()
这是显示每个传感器温度随日期时间变化的代码。每个传感器将根据其id具有不同的颜色。我以4个传感器id为例:
相关问题 更多 >
编程相关推荐