I want to apply a function that creates a column based on variables in 2 other columns.
One column
'SSPstaterank'returns the suburb ranking.The second column
'SSPstaterank%'returns the suburb ranking percentile.
I thought this code would work, but it returns:
TypeError: ("'DataFrame' object is not callable", 'occurred at index 0')
def func1 (a,b):
if a == 1:
return 'the #1 suburb'
elif b >= 0.95:
return 'ranked top 5% of suburbs'
elif b >= 0.9:
return 'ranked top 10% of suburbs'
else:
return 'none'
df2['rankdescript'] = df2.apply(lambda x: df2(x['SSPstaterank'], x['SSPstaterank%']), axis=1)