我有一分鐘間隔的市場營銷數據。 爲CSV-表的一個樣本,每一行代表爲每分鐘最大值:查找pd.DateFrame中每5行的最大值
time ch1 ch2 ch3 ch4
20:03 1754 539 149 1337
20:04 2073 576 160 1448
20:05 2246 599 176 1515
20:06 2246 637 176 1531
20:07 2457 651 183 1549
20:08 2564 677 184 1655
20:09 2624 712 191 1699
20:10 2742 717 194 1672
20:11 2788 714 199 1675
20:12 2792 693 186 1680
20:13 2914 708 188 1672
20:14 3067 715 194 1685
20:15 3067 725 196 1682
另外,我需要找到最大值,每次5分鐘。因此,我需要爲每列的每5行(或更少 - 如果沒有更多行保留)找到最大值並將其插入新的5分鐘行。
我希望收到(爲例):
每個新行都有代表5
time ch1 ch2 ch3 ch4
20:03 2564 677 184 1655
20:08 2914 717 199 1699
20:13 3067 725 196 1685
老實說,我已經搜查,但沒有結果最大值。
有沒有在Python中爲我的任務提供一些優雅的解決方案? 感謝您的幫助!
謝謝!但在數據集中有幾天(15.09,16.09,17.09)。你現在,如何設定不同日期的日期? (因爲它會是.xls格式,而不僅僅是.csv)。 – Gregof
您是否可以更新您的樣本以包含日期?如果它只是一列日期,則可以合併列並將其設置爲日期時間對象 – DJK