'Multi conditions if clauses does not work properly
I want to add a new column in a df according to values in two columns. My code is like this but all conditions are not met when run my code:
def Modify_location_df(df):
if (df['Family'] != 'Roof') and (df['Reference Level Elevation'] == '0'):
return 'First Floor'
elif (df['Family'] != 'Roof') and (df['Reference Level Elevation'] == '335'):
return 'Attic floor'
else:
return 'Pitched Roof'
df['Location'] = df.apply(Modify_location_df, axis = 1)
My Data frame before applying the code
My Data frame after applying the code (the first row should be 'Pitched roof' but it's not)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
