2
我有在公里每小時速度列中的熊貓數據幀,以及時間戳列:如何找到大熊貓數據框中諧波平均速度
Date, Speed
2016-07-07 13:38:02.000, 50.718590
2016-07-18 11:28:00.000, 2.357645
2016-07-15 15:03:08.000, 14.652172
2016-07-18 06:53:00.000, 24.530390
... ...
2016-07-18 18:41:31.000, 31.761416
2016-07-14 05:28:42.187, 7.532758
我想是有,每次15分鐘harmonic average speed在平均每天:
Time, Speed
00:00, 32
00:15, 10
00:30, 12
00:45, 41
01:00, 12
...
23:30, 30
23:45, 31
我最初的嘗試是從每一個時間戳刪除的日期,將其設置爲指標,並使用TimeGrouper找到平均值。 (我的數據框被稱爲輸出)的代碼是:
Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'Int64Index'
提取作爲一個字符串只是時間你能嘗試沒有第一行,你只改變你的日期時間,只是'output = output.set_index(['Date']) output = output.groupby(pd.TimeGrouper('15Min'))。mean()' – EdChum
它不會創建錯誤,但是它會創建從第一個日期到最後一個日期每15分鐘的平均速度,而我會螞蟻每天平均爲一個。 –
好吧,你可以做的一件事就是通過這個'pd.to_datetime(df ['date']。dt.strftime('%H:%M:%S'))來標準化日期''這會將日期設置爲對所有參賽作品都是一樣的,那麼你可以做你之前做的事情 – EdChum