Net-informations.com

DataFrame Aggregation and Grouping

Pandas aggregate() function is used to apply some aggregation across one or more column.

Above statement will apply aggregation across all the columns in a DataFrame and calculate sum and min will be found for each numeric type column.

Lets create a DataFrame..

The following operation will apply aggregation across all the columns in a DataFrame and calculate minimum and maximum will be found for each numeric type column.

DataFrame aggregation across different columns

Aggregation with groupby

For multiple functions applied for one column use a list of tuples - names of new columns and aggregated functions:

If you want to pass multiple functions is possible pass list of tuples.

Instead of an aggregation function it is possible to pass list, tuple, set for converting column.

For converting to strings with separator use .join only if string column.

Some common aggregating functions are tabulated below:

Function Description
mean() Compute mean of groups
sum() Compute sum of group values
size() Compute group sizes
count() Compute count of group
std() Standard deviation of groups
first() Compute first of group values
last() Compute last of group values
min() Compute min of group values
max() Compute max of group values









net-informations.com (C) 2022    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.
SiteMap  | Terms  | About