If the minimum time delta between dates is greater than 1 day, data_df.resample(min_timestep(data_df)).mean() encounters a 'ZeroDivisionError: integer modulo by zero] because time_delta.min().seconds in the min_timestep function returns 0s, thus triggering the condition of the first if statement.