1 Resampler.quantile(q = 0.5, **kwargs)
1 import pandas as pd
2
3 idx = pd.DatetimeIndex(['2023-01-01', '2023-01-5', '2023-01-10',
4 '2023-02-01', '2023-02-10', '2023-02-15'])
5 ser = pd.Series([1, 2, 1, 3, 5, 7], index = idx)
6
7 sample = ser.resample('MS')
8
9 res = sample.quantile()
10 print('The quantile of each group :')
11 print(res)
1 The quantile of each group :
2 2023-01-01 1.0
3 2023-02-01 5.0
4 Freq: MS, dtype: float64
1 import pandas as pd
2
3 idx = pd.date_range('20230101', periods = 5, freq = 'h')
4 ser = pd.Series([1, 2, 3, 4, 5], index = idx)
5
6 sample = ser.resample('2h')
7
8 res = sample.quantile()
9 print('The quantile of each group :')
10 print(res)
1 The quantile of each group :
2 2023-01-01 00:00:00 1.5
3 2023-01-01 02:00:00 3.5
4 2023-01-01 04:00:00 5.0
5 Freq: 2h, dtype: float64