df["A"].value_counts()
(25.0, 38.0] 361594
(12.999, 25.0] 330552
(55.0, 218.0] 305439
(38.0, 55.0] 231683
Name: A, dtype: int64
我們有以下間隔,每當有新資料點到來時,我都需要映射到以下間隔。我想要這樣的東西。
def func_(x):
if (x> 12.999) & (x< 25.0):
return (12.999, 25.0]
elif:
for rest of bucket range
uj5u.com熱心網友回復:
您可以bins按以下方式生成的類別重用引數CategoricalIndex.categories:
s = df["A"].value_counts()
print (pd.cut(df['new'], bins=s.index.categories))
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/352675.html
