Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一系列 633 个值,其中约 50% 为 0。理想情况下,我想使用 对我的值(用于 choropleth 映射目的)进行分类qcut(),但由于非唯一的 bin 边缘,这给了我一个错误。分离数据、对非零值进行分位数然后将它们重新组合成一列以使零值的值为 0 且分位数为 0 的最佳方法是categorical.label + 1什么?
qcut()
categorical.label + 1
如果您将零值替换为NaN,cut()并按qcut()预期运行;这些行的 bin 值(来自Categorical.labels)为-1:
NaN
cut()
Categorical.labels
-1
df['density'].replace(to_replace=0, value=np.nan, inplace=True)