pandas高级函数操作总结
发布时间
阅读量:
阅读量
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
全部评论 (0)
还没有任何评论哟~
