【发布时间】:2020-09-08 09:10:31
【问题描述】:
当我尝试合并列值时出现错误,我的代码如下,
bins = [1, 10, 20, 34, np.inf]
labels = ['1-10', '10-19', '20-34', '34+']
df['binned'] = pd.cut(df['Location Count'], bins=bins, labels=labels, include_lowest=True)
其中位置计数列包含数值,例如 1.0 或 20.0,
当我的分箱列中的位置计数值为 20.0 时,这给了我一个分箱值,即 10-19,我在我的代码中做错了吗?谢谢
【问题讨论】:
标签: python python-3.x pandas