I am trying to update the values of column 'Age' using the apply()
method.
I want to update the ages into 2 specific values. This is the function.
def new_age(a):
if a<25:
return 'pro'
else:
return 'notpro'
When I pass the apply function df['Age'].apply(new_age)
it works fine but when i try to update the values of the "Age" column using df['Age']=df['Age'].apply(new_age)
it returns NaN.
Can I get some help?
Edit: I tried the map() function. It did nothing better.