-1

I want to resample a dataset, the minimum date of each series should be the same for each series, therefore, the minimum date of each series should be the minimum value for the date column. Same for the maximum date (Instead of resampling at series level, I want to resample taking the global maximum value).

And this, opens a new question, how do I specify when resampling that the null values that I want a 0.

I mean, suppose this case:

series col date value
series_1 2023-02-06 5
series_1 2023-02-23 7

If you notice, I miss the series in between: (resampling on weeks)

series col date value
series_1 2023-02-13 0

I'm wondering what is the following code doing? how is filling that value? Because I have not specified anything and I don't see null values when I'm resampling.pandas documentation

df.groupby('series_col').resample('W', on='date', label='left', loffset=pd.DateOffset(days=0))['value'].sum().reset_index()
Pedro Rocha
  • 1,373
  • 1
  • 3
  • 14
Tonino Fernandez
  • 441
  • 4
  • 12
  • Can you clarify your question? And provide a reproducible input as DataFrame constructor (I imagine the date column has a datetime type). – mozway Feb 28 '23 at 15:50

1 Answers1

1

You can use a weak calendar table as a dimension and do a full join on your data

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 04 '23 at 21:52