I am trying to create a new column based on the condition of another column, with ranges of that count. However, I am getting a ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
I am trying to use the same column twice to make the range, but it does not work. Where is the problem?
df.loc[(df["count_words"] > 100 & df["count_words"] <= 300), "length"] = "keskipitkä"
df.loc[df["count_words"] <= 100, "lenght"] = "lyhyt"
df.loc[df["count_words"] > 300, "length"] = "pitkä"