rand_val new_val copy_time
2020-10-15 00:00:00 7 26 2020-10-15 00:00:00
2020-10-15 00:00:10 8 29 2020-10-15 00:00:10
2020-10-15 00:00:20 1 53 2020-10-15 00:00:20
2020-10-15 00:03:50 6 69 2020-10-15 00:03:50
2020-10-15 00:04:00 3 19 2020-10-15 00:04:00
I am using the method resample to downsample the time-series. I have found I cannot call the specific columns when applying a function on the aggregated data.
Let's say I want to do some operation that involves calling the name of a column:
df.resample("1min").apply(lambda x: sum(x.rand_val) if len(x)>1 else 0)
I get an error:
AttributeError: 'Series' object has no attribute 'rand_val'
This would be possible if I had done groupby on some other variable. I guess the resample function is not the same. Any ideas?