我有大量从传感器收集的数据集。我想使用平均值每五分钟对每列数据进行分组。有很多NaN值。有人能帮我吗?数据信息和前20行显示在这里:
datasets.info()
[20 rows x 11 columns]
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1083433 entries, 0 to 1083432
Data columns (total 11 columns):
Time 1083433 non-null object
Temp (back) 132639 non-null object
Temp (front) 104623 non-null object
Temp (out) 104797 non-null object
Humidity (back) 132610 non-null object
Humidity (front) 104718 non-null object
Humidity (out) 104798 non-null object
CO2 (front) 104713 non-null object
CO2 (out) 104790 non-null object
Door Open 104677 non-null object
Motion 104415 non-null object
dtypes: object(11)
memory usage: 90.9+ MB
print(datasets.head(20))
Time Temp (back) ... Door Open Motion
0 2018-09-06T07:52:09+02:00 24.79 ... NaN NaN
1 2018-09-06T07:52:09+02:00 NaN ... NaN NaN
2 2018-09-06T07:53:07+02:00 24.79 ... NaN NaN
3 2018-09-06T07:53:07+02:00 NaN ... NaN NaN
4 2018-09-06T07:54:06+02:00 24.79 ... NaN NaN
5 2018-09-06T07:54:06+02:00 NaN ... NaN NaN
6 2018-09-06T07:55:04+02:00 24.8 ... NaN NaN
7 2018-09-06T07:55:04+02:00 NaN ... NaN NaN
8 2018-09-06T07:56:03+02:00 24.77 ... NaN NaN
9 2018-09-06T07:56:03+02:00 NaN ... NaN NaN
10 2018-09-06T07:57:01+02:00 24.77 ... NaN NaN
11 2018-09-06T07:57:01+02:00 NaN ... NaN NaN
12 2018-09-06T07:58:00+02:00 24.77 ... NaN NaN
13 2018-09-06T07:58:00+02:00 NaN ... NaN NaN
14 2018-09-06T07:58:59+02:00 24.79 ... NaN NaN
15 2018-09-06T07:58:59+02:00 NaN ... NaN NaN
16 2018-09-06T07:59:58+02:00 24.77 ... NaN NaN
17 2018-09-06T07:59:58+02:00 NaN ... NaN NaN
18 2018-09-06T08:00:57+02:00 24.82 ... NaN NaN
19 2018-09-06T08:00:57+02:00 NaN ... NaN NaN
datasets['Time']=pd.to_datetime(datasets['Time'])
datasets.groupby(pd.Grouper(freq='5Min')).mean()
TypeError: Only valid with DatetimeIndex, TimedeltaIndex or
PeriodIndex, but got an instance of 'RangeIndex'