These functions accept a similar set of parameters and compute the aggregates (min, max, median, or mode) for each column or row based on the axis parameter setting:
sales_df.min()
The following is the output:
The max method can be applied as shown here:
sales_df.max(axis = 1)
The following is the output:
The skipna parameter helps us handle NAs. Consider the following DataFrame:
sales_df_na
The following is the output:
By default, the NAs are skipped during evaluation, as the skipna parameter is set to True:
sales_df_na.median()
The following is the output:
By default, NAs are ignored in mean calculations. If skipna is set to False, the calculation also result to NA if there is a missing value:
sales_df_na.median(skipna = False)
The following is the output:
Consider the following multi indexed DataFrame. Let's compute the mean for it:
multileveldf
The following is the output:
The mean of this multi-index dataset can be obtained as shown here:
multileveldf.mean()
The following is the output:
The level parameter computes the aggregate across any level of index in a multi-indexed DataFrame:
multileveldf.mean(level = 0)
The following is the output: