Comment by short_sells_poo

5 days ago

It's actually much simpler than that. Assuming the index of the dataframe DF is composed of timestamps (which is normal for timeseries):

df.resample("BME").sum()

Done. One line of code and it is quite obvious what it is doing - with perhaps the small exception of BME, but if you want max readability you could do:

df.resample(pd.offsets.BusinessMonthEnd()).sum()

This is why people use pandas.