美文网首页
pandas函数-cut

pandas函数-cut

作者: 橘猫吃不胖 | 来源:发表于2020-06-07 15:16 被阅读0次

pandas.cut

pandas.cut(x, bins, right: bool = True, labels=None, retbins: bool = False, precision: int = 3, include_lowest: bool = False, duplicates: str = 'raise')

Use cut when you need to segment and sort data values into bins. This function is also useful for going from a continuous variable to a categorical variable. For example, cut could convert ages to groups of age ranges. Supports binning into an equal number of bins, or a pre-specified array of bins.

这个函数用来对数据进行分割,比如在做直方图的时候,就可以使用

最基本的参数一个是x,一个是要分割的份数

rs = pd.cut(np.array([1, 7, 5, 4, 6, 3]), 3)

我们传入一组数据,然后分成3份,返回的结果就是区间

相关文章

网友评论

      本文标题:pandas函数-cut

      本文链接:https://www.haomeiwen.com/subject/phlazhtx.html