October 2019
Beginner to intermediate
674 pages
16h 43m
English
For any DataFrame, a list of aggregations can be performed after applying groupby. In the following example, the mean and standard deviation have been computed for Sales and Quantity:
sales_data[["Sales", "Quantity", "Category"]].groupby("Category").agg([np.mean, np.std])
The following will be the output:

Note that hierarchy has also been introduced in the column index. agg is a short form of aggregate. These aggregations will exclude any NAs found for computation.
In the preceding example, columns were created with the mean and std labels. Let's try renaming them. The rename argument maps ...
Read now
Unlock full access