I am having difficulties creating a new column with a value that's based on the value of an existing column in that same dataframe. The existing column is numeric and I'm trying give the new column a categorical value of high, medium, low based on something like:
low: < (max-min)/3
med: (max-min)/3 - (max-min)/3 *2
high: > (max-min)/3 *2
Still learning Pandas, so any help is appreciated. Thanks!
EDIT:
This is what I have attempted:
df_unit_day_hour['Level_Score'] = pd.cut(df_unit_day_hour['Level_Score'], q=3, labels=['low', 'medium', 'high'])
I think it's almost what I need, but I'm getting an error (KeyError). Would it be because df_unit_day_hour['Level_Score'] is a float?