I was reading a lot of stuff about pandas and date time slicing but I haven't found a solution for my problem yet. I hope you could give me some good advices! I have a data frame with a Datetimeindex and for example a single column with floats. The time series is about 60 years. For example:
idx = pd.Series(pd.date_range("2016-11-1", freq="M", periods=48))
dft = pd.DataFrame(np.random.randn(48,1),columns=["NW"], index=idx)
I want to aggregate the column "NW" as sum() per month. I have to solve two problems.
- The year begins in November and ends in October.
- I have two periods per 12 months to analyse: a) from November to End of April in the following year and b) from May to End of October in the same year For example: "2019-11-1":"2020-4-30" and "2020-05-01":"2020-10-31"
I think I could write a function but I wonder if there is an easier way with methods from pandas to solve this problems.
Do you have any tips? Best regards Tommi.
Here are some additional informations:
The real datas are daily observations. I want to show a scatter plot for a time series with only the sum() for every month from November-April along the timeline (60 years til now). And the same for the values from May to October.