By using to_datetime() we got datetime column my_date
We will resample the above DataFrame using 2 minutes interval and using the aggregate function sum() for the value column. ( we can use other aggregate functions like mean, max , min , std() here. )
value c_right
my_date
2022-06-01 00:00:00 2 2.5
2022-06-01 00:01:00 2 NaN
2022-06-01 00:02:00 3 2.0
2022-06-01 00:03:00 1 NaN
2022-06-01 00:04:00 3 2.0
2022-06-01 00:05:00 2 NaN
As per the manual
Which side of bin interval is closed. The default is ‘left’ for all frequency offsets except for 'M', 'A, 'Q', 'BM', 'BA', 'BQ', and 'W' which all have a default of 'right'.
label: As per the manual ..
Which bin edge label to label bucket with. The default is 'left' for all frequency offsets except for 'M', 'A', 'Q', 'BM', 'BA', 'BQ', and 'W' which all have a default of 'right'.
value l_right
my_date
2022-06-01 00:00:00 2 NaN
2022-06-01 00:01:00 2 NaN
2022-06-01 00:02:00 3 4.0
2022-06-01 00:03:00 1 NaN
2022-06-01 00:04:00 3 4.0
2022-06-01 00:05:00 2 NaN
on: In our examples above the date time column ( my_date ) is the index coloumn. If the resample is to be applied to any other column ( must be date-time ) then on can be used to provide column name.