Home > Net >  Date range with occurrence sum
Date range with occurrence sum

Time:12-31

I have a potentially big dataframe containing datetimes sourced from a date range query as such:

0   2022-11-20 00:02:22.630968 00:00
1   2022-11-23 00:03:02.134938 00:00
2   2022-11-23 00:03:50.589251 00:00
3   2022-11-26 00:05:17.568843 00:00
4   2022-11-26 00:05:22.653905 00:00
5   2022-11-26 00:05:22.653905 00:00
6   2022-11-26 00:05:22.653905 00:00

I need to reshape it into a list of date with number of date occurrences in the second row, no date occurrence must be zero filled as such:

2022-11-20 1
2022-11-21 0
2022-11-22 0
2022-11-23 2
2022-11-24 0
2022-11-25 0
2022-11-26 4

What is the most efficient way to achieve that with Pandas ?

If that's useful.. the end goal is to feed that data to enter image description here

Intermediates :

2022-11-20    1
2022-11-21    0
2022-11-22    0
2022-11-23    2
2022-11-24    0
2022-11-25    0
2022-11-26    4
Freq: D, Name: Datetime, dtype: int64 <class 'pandas.core.series.Series'>
  • Related