aliyun / aliyun-odps-python-sdk

ODPS Python SDK and data analysis framework
http://pyodps.readthedocs.io
Apache License 2.0
434 stars 97 forks source link

Quantile对象应该如何使用 #101

Closed StepSnail closed 5 years ago

StepSnail commented 5 years ago

想要使用pandas的qcut方法直接对一列数据进行划分,可是pyodps中pandas的版本好像不支持duplicates关键字,所以我使用了pyodps中dataframe的quantile()方法来求分位值,可是返回的是一个odps.df.expr.core.Quantile对象,打印出来可以看到结果,但是不知道它有哪些属性和方法,文档中也没有介绍,不知道如何使用。

lli27 commented 5 years ago

quantile = df.column.quantile([0.25,0.75]).execute() #返回某列分位数的值,对象是数组 df.apply(lambda row: 1 if df.column<=quantile[0] else 2 if df.column<=quantile[1] else 3, reduce=True, names=[column_name],axis=1,types=['int64']) #根据分位数的值对连续列分箱