ทำความสะอาดข้อมูล time series

การแสดงภาพข้อมูล Time Series ด้วย Python

Thomas Vincent

Head of Data Science, Getty Images

ข้อมูล time series ระดับ CO2

ตัวอย่างข้อมูลการวัดระดับ CO2 รายสัปดาห์ที่หอดูดาว Mauna Loa รัฐฮาวาย

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
การแสดงภาพข้อมูล Time Series ด้วย Python

ค้นหาค่าที่ขาดหายใน DataFrame

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
...
การแสดงภาพข้อมูล Time Series ด้วย Python

นับค่าที่ขาดหายใน DataFrame

print(df.isnull().sum())
datestamp     0
co2          59
dtype: int64
การแสดงภาพข้อมูล Time Series ด้วย Python

แทนที่ค่าที่ขาดหายใน DataFrame

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
...
การแสดงภาพข้อมูล Time Series ด้วย Python

มาฝึกกันเถอะ!

การแสดงภาพข้อมูล Time Series ด้วย Python

Preparing Video For Download...