How to categorise a value, based on grouped values

Hi
I’m working on a personal project for property data. I am trying to classify a value (floor height) based on a grouped variable (by town).

I have a function here , but its not quite working. Can someone suggest another way to do this?

> def classify_floor(x):
    if x> combined2['high_floor_cap']:
        return "high"
    elif x< combined2['low_floor_cap']:
        return "low"
    else:
        return "mid"

test_class = combined['storey_start'].apply(classify_floor)
test_class.head()    

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

Here is a sample of the data.

Hi @gayletan

Welcome to our Dataquest Community.

I have taken an example and trying to do the same thing. Please see the image and correct your errors.

Let me know if you need more info :slightly_smiling_face: .

Can i use this method on a single column, or is that not how it should be done?

eg:
df[col2].apply(classify_floor)

Yes, You can do it on a single column.