当我使用groupby时,为什么分位数(0.5)和中值输出结果不同?

2024-06-28 19:47:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用groupby函数,后跟中值,但当我将中值更改为分位数(0.5)时,结果不同。为什么

df.groupby(['PUMA', 'R65'])['HINCP'].quantile(0.5)

df.groupby(['PUMA', 'R65'])['HINCP'].median()

上面应该是一样的吧

check the screenshot

仅供参考。数据集在这里:https://github.com/kihyukh/stats206/raw/master/data/pums_short.csv.gz

我的熊猫版本是1.0.1


Tags: 数据函数httpsgithubcomdfmediangroupby