1.pandas中的列的分位数
# 查看列的分位数
import pandas as pd
# set columns type
my_df['col'] = my_df['col'].astype(np.float64)
# computations for 4 quantiles : quartiles
bins_col = pd.qcut(my_df['col'], 4)
bins_col_label = pd.qcut(my_df['col'], 4).labels
2.多重聚合(组函数)
# 多重聚合(组函数)
# columns settings
grouped_on = 'col_0' # ['col_0', 'col_2'] for multiple columns
aggregated_column = 'col_1'
### Choice of aggregate functions
## On non-NA values in the group
## - numeric choice :: mean, median, sum, std, var, min, max, prod
## - group choice :: first, last, count
# list of functions to compute
agg_funcs = ['mean', 'max']
# compute aggregate values
aggregated_values = my_df.groupby(grouped_on)[aggregated_columns].agg(agg_funcs)
# get the aggregate of group
aggregat