我從熊貓得到一個奇怪的行爲,我想重新採樣我的分鐘數據到小時數據(使用均值)。我的數據如下所示:熊貓重採樣不能正常工作
Data.head()
AAA BBB
Time
2009-02-10 09:31:00 86.34 101.00
2009-02-10 09:36:00 86.57 100.50
2009-02-10 09:38:00 86.58 99.78
2009-02-10 09:40:00 86.63 99.75
2009-02-10 09:41:00 86.52 99.66
Data.info()
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 961276 entries, 2009-02-10 09:31:00 to 2016-02-29 19:59:00
Data columns (total 2 columns):
AAA 961276 non-null float64
BBB 961276 non-null float64
dtypes: float64(2)
memory usage: 22.0 MB
Data.index
Out[25]:
DatetimeIndex(['2009-02-10 09:31:00', '2009-02-10 09:36:00',
'2009-02-10 09:38:00', '2009-02-10 09:40:00',
'2009-02-10 09:41:00', '2009-02-10 09:44:00',
'2009-02-10 09:45:00', '2009-02-10 09:46:00',
'2009-02-10 09:47:00', '2009-02-10 09:48:00',
...
'2016-02-29 19:41:00', '2016-02-29 19:42:00',
'2016-02-29 19:43:00', '2016-02-29 19:50:00',
'2016-02-29 19:52:00', '2016-02-29 19:53:00',
'2016-02-29 19:56:00', '2016-02-29 19:57:00',
'2016-02-29 19:58:00', '2016-02-29 19:59:00'],
dtype='datetime64[ns]', name='Time', length=961276, freq=None)
要重新取樣我做數據如下:
tframe = '60T'
hr_mean = Data.resample(tframe).mean()
而作爲輸出我得到的熊貓系列只有兩個數字在它:
In[26]: hr_mean
Out[26]:
AAA 156.535198
BBB 30.197029
dtype: float64
如果我選擇不同的時間範圍或重新採樣函數,我會得到相同的行爲。
你可以給你使用的熊貓版本嗎? – joris