python resample problem with different year

30 Views Asked by At

when i resample df like bllow, it return len(df) =2

df = df.resample('100Y').agg({'Open': 'first', 'High': 'max', 'Low': 'min', 'Close': 'last'})
original df is :
2023-12-31 02:02:59.999000064+09:00,103.38000,103.46000,103.36000,103.42000,1201.72000,159.00000
.....
.....
2023-12-31 23:59:59.999000064+09:00,102.82000,103.03000,102.80000,102.99000,3464.82000,343.00000
2024-01-01 00:00:59.999000064+09:00,102.99000,103.03000,102.76000,102.85000,2839.42000,316.00000
.....
.....
2024-01-01 00:53:59.999000064+09:00,102.38000,102.39000,102.35000,102.36000,1275.77000,836.00000

i got this:

2023-12-31 23:59:59.999000064+09:00,103.39000,103.39000,102.77000,102.99000
2023-01-01 00:00:00.999000064+09:00,102.99000,103.71000,102.15000,102.36000

i hope it will be marged to 1 row , how can i do this ?

itried add loffset = '-365d' but didnt work

0

There are 0 best solutions below