March 2020
Beginner to intermediate
352 pages
8h 40m
English
Working with groupby() and aggregation, you must have thought, why can't we group data, apply aggregation, and append the result into the dataframe directly? Is it possible to do all this in a single step? Yes, it is.
Performing a transformation on a group or a column returns an object that is indexed by the same axis length as itself. It is an operation that's used in conjunction with groupby(). The aggregation operation has to return a reduced version of the data, whereas the transformation operation can return a transformed version of the full data. Let's take a look:
df["price"]=df["price"].transform(lambda ...
Read now
Unlock full access