作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在如何调用四分位数时遇到问题。这是 csv 文件:drinksbycountry.csv我创建了新列,其中显示“啤酒份量”列中值(value)的分位数。
df['nowa'] = pd.qcut(df['beer_servings'],6)
df.loc[1:5,['country', 'continent0','nowa' ]]
结果:
我不想有这样的间隔:(225.0, 376.0]。我想显示:“组 1”、“组 2”如何做到这一点?
最佳答案
使用参数标签
:
labels : array or boolean, default None
Used as labels for the resulting bins. Must be of the same length as the resulting bins. If False, return only integer indicators of the bins.
df['nowa'] = 'group ' + pd.qcut(df['beer_servings'],6, labels=False).astype(str)
也可以在列表中创建标签 - 例如在使用 f-string
s 进行列表理解时:
labels = [f'group {x}' for x in range(6)]
df['nowa'] = pd.qcut(df['beer_servings'],6, labels=labels)
关于python - 如何称呼四分位数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55488757/
所以我正在尝试使用 C++ 中的 GLFW 和 GLEW 编写一个简单的 3D 渲染引擎。然而,程序在 glDrawArrays(GL_TRIANGLES, 0, model.indicesCount
我是一名优秀的程序员,十分优秀!