pandas.cut用来把一组数据分割成离散的区间。比如一组年龄数据,pandas.cut将年龄分割成不同的年龄段并打上标签。
pandas.cut(x, bins, right=True, labels=None, retbins=False, precision=3,include_lowest=False, duplicates=‘raise‘)
x:被切分的类数组数据,必须是1维的(不能是DataFrame)。
bins:bins是被切割后的区间,有3种形式:int、数组、pandas.IntervalIndex
int
来自: ColdCode
原文:https://www.cnblogs.com/keye/p/13218620.html