Pandas df.resample with column-specific aggregation function

Viewed 16024

With pandas.DataFrame.resample I can downsample a DataFrame:

df.resample("3s", how="mean")

This resamples a data frame with a datetime-like index such that all values within 3 seconds are aggregated into one row. The values of the columns are averaged.

Question: I have a data frame with multiple columns. Is it possible to specify a different aggregation function for different columns, e.g. I want to "sum" column x, "mean" column y and pick the "last" for column z? How can I achieve that effect?

I know I could create a new empty data frame, and then call resample three times, but I would prefer a faster in-place solution.

2 Answers
Related