I have a dataframe with two datetime columns and a third column with a numeric value. Here is an example:
2019-01-01 00:00:00 2019-12-31 00:00:00 118433.0
2020-01-01 00:00:00 2020-12-31 00:00:00 120087.0
2021-01-01 00:00:00 2021-06-30 00:00:00 63831.0
2021-07-01 00:00:00 2021-12-31 00:00:00 63089.0
2022-01-01 00:00:00 2022-06-30 00:00:00 60753.0
2022-07-08 00:00:00 2022-11-30 00:00:00 9067.17
As you can see while 2019 and 2020 are full years, the other rows describe different time spans.
I need to sum all the numeric values pertaining to the same year to get something like:
2019 118422.0
2020 120087.0
2021 123842.0
2022 9067.0
The from-to dates on every row always fall in the same year.
Any given year does not have to be a full year.
I'd love to avoid simple iterations and learn a properly pythonic way of achieving this (list comprehension / vectorization).
Thank you