用 Python 可视化时间序列数据
Thomas Vincent
Head of Data Science, Getty Images
夏威夷茂纳罗亚观测站每周 CO2 浓度测量的片段。
datastamp co2
1958-03-29 316.1
1958-04-05 317.3
1958-04-12 317.6
...
...
2001-12-15 371.2
2001-12-22 371.3
2001-12-29 371.5
print(df.isnull())
datestamp co2
1958-03-29 False
1958-04-05 False
1958-04-12 False
print(df.notnull())
datestamp co2
1958-03-29 True
1958-04-05 True
1958-04-12 True
...
print(df.isnull().sum())
datestamp 0
co2 59
dtype: int64
print(df)
...
5 1958-05-03 316.9
6 1958-05-10 NaN
7 1958-05-17 317.5
...
df = df.fillna(method='bfill')
print(df)
...
5 1958-05-03 316.9
6 1958-05-10 317.5
7 1958-05-17 317.5
...
用 Python 可视化时间序列数据