I have 1-minute bitcoin data, which I need to group into 5-minute data. I am using pd.Grouper function in order to achieve this task, here is my code:
df_5min = df_5min = df.groupby(pd.Grouper(key="Date_Time", freq = '5min', origin='epoch', dropna=False)).agg({
"Open": "first",
"High": "max",
"Low": "min",
"Close": "last",
"Volume_(BTC)": "sum",
"Volume_(Currency)": "sum"})
If you look at my original dataframe(1 minute data), there is no rows with NaN's.
But when I group the data into 5-minute data using the above code, I get a lot of NaN's:
I checked my 1-minute data to see if there are missing values in that time period:
As it can be seen, indeed there are missing values, but that is the case with other minutes group as well, like between 2:00:00 to 2:05:00 there is only one value 2:04:00 and so on.
What might be giving me these NaN's and how can I avoid this? I would like to get the aggregation as mentioned in my above code.


