我想將 DataFrame 繪制為時間序列
import matplotlib.pyplot as plt
plt.plot(df['time'],df['Power'])
或者
df2 = df.set_index('time')
df2.Power.plot()
它們都正確顯示了所有 3531 個 y 值,但 x 軸時間標簽錯誤,例如 25 秒而不是 25 分鐘。

時間戳不是完全規則的,并且有 ms 小數
0 2022-05-16 19:59:25.690
1 2022-05-16 19:59:25.890
2 2022-05-16 19:59:26.100
3 2022-05-16 19:59:26.320
4 2022-05-16 19:59:26.530
...
3526 2022-05-16 20:24:51.690
3527 2022-05-16 20:24:52.420
3528 2022-05-16 20:24:52.740
3529 2022-05-16 20:24:53.210
3530 2022-05-16 20:24:54.570
Name: time, Length: 3531, dtype: datetime64[ns]
我錯過了什么?
uj5u.com熱心網友回復:
您應該使用
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/475964.html
標籤:Python 熊猫 约会时间 matplotlib 数据可视化
