I'm trying to use pandas to resample 15 minute periods into 1 hour periods but by applying a custom function. My DataFrame is in this format;
Date val1 val2
2016-01-30 07:00:00 49.0 45.0
2016-01-30 07:15:00 49.0 44.0
2016-01-30 07:30:00 52.0 47.0
2016-01-30 07:45:00 60.0 46.0
2016-01-30 08:00:00 63.0 61.0
2016-01-30 08:15:00 61.0 60.0
2016-01-30 08:30:00 62.0 61.0
2016-01-30 08:45:00 63.0 61.0
2016-01-30 09:00:00 68.0 60.0
2016-01-30 09:15:00 71.0 70.0
2016-01-30 09:30:00 71.0 70.0
..and i want to resample with this function;
def log_add(array_like):
return (10*math.log10((sum([10**(i/10) for i in array_like])))))
I do;
df.resample('1H').apply(log_add)
but this returns an empty df, doing this;
df.resample('1H').apply(lambda x: log_add(x))
does the same too. Anyone any ideas why its not applying the function properly?
Any help would be appreciated, thanks.