rwijtvliet / portfolyo

Handling timeseries for power and gas retail portfolios.
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

[enhancement] Aggregation to non-calendar periods #57

Closed rwijtvliet closed 2 months ago

rwijtvliet commented 9 months ago

Currently, the aggregation for PfLine and PfState instances is done with .asfreq(freq), with the parameter freq being "MS", "QS", or "'AS'", to aggregate to monthly, quarterly, or yearly values.

What is not yet possible, is to aggregate to e.g. business years (let's say starting at April 1), or to time periods of e.g. 15 months.

The following proposal (up for discussion):

  1. Allow not only "AS", but also e.g. "AS-APR" as value for freq. This would aggregate the values between April 1 0:00 (incl) and April 1 0:00 (excl) the next year. Compare:
>>> pd.date_range('2022', freq="AS-APR", periods=10)
DatetimeIndex(['2022-04-01', '2023-04-01', '2024-04-01', '2025-04-01',
               '2026-04-01', '2027-04-01', '2028-04-01', '2029-04-01',
               '2030-04-01', '2031-04-01'],
              dtype='datetime64[ns]', freq='AS-APR')
  1. For more exotic aggregations, allow "all" as value for freq. This would aggregate over all time periods in the PfLine or PfState. Here, the implications are a bit more difficult, as this is not supported out of the box by pandas.
rwijtvliet commented 3 months ago

See attached xlsx for more elaborate explanation explainer.xlsx

rwijtvliet commented 2 months ago
image