So, I am trying to create a new pandas column describing hardiness zones (8b, 8a, 7b, 7a) based off of longitude which is stored in another column. I am trying to say that any longitude below this value falls into a certain zone and so on. However, when I run this code it does create a new column but everything comes out as 8b.
def group_zone(row):
if long_list[1] < -122.2:
return '8b'
elif long_list[1] < -122.0:
return '8a'
elif long_list[1] < -121.6:
return '7b'
else:
return '7a'
data.apply(lambda row: group_zone(row), axis=1)
data['zone'] = data.apply(lambda row: group_zone(row), axis=1)
data.head()