I am trying to categorized "DistAreaID
" column of my dataset [cf_all
] by grouping to its mean wrt Y.
Code:
round(cf_all.groupby("DistArea_ID")["Counterfeit_Sales"].mean(), 2)
for col in range(len(cf_all)):
if cf_all["DistArea_ID"][col] in \
["Area013", "Area017", "Area018", "Area035", "Area045", "Area046", "Area049"]:
cf_all.loc[col, "DistArea_ID"] = "DistArea_2000"
if cf_all["DistArea_ID"][col] in ["Area010", "Area019"]:
cf_all.loc[col, "DistArea_ID"] = "DistArea_400"
if cf_all["DistArea_ID"][col] in ["Area027"]:
cf_all.loc[col, "DistArea_ID"] = "DistArea_3000"
Error:
The truth value of a Series is ambiguous. Use a.empty, a.bool(),
a.item(), a.any() or a.all().
Can someone please guide me with this error?
cf_all
? – shaik moeed(cf_all["DistArea_ID"] [col] in ["Area013","Area017","Area018","Area035","Area045","Area046","Area049"]).any()
– shaik moeed