I have a function as defined below:
def season_map(x):
return x.map({1:'spring',2:'summer',3:'fall',4:'winter'})
Now on calling the function on season column which only contains values 1, 2, 3 or 4:
bike_data['season'] = bike_data['season'].apply(season_map)
The error given is: AttributeError: 'int' object has no attribute 'map'
But if I try:
bike_data['season'] = bike_data['season'].map({1:'spring',2:'summer',3:'fall',4:'winter'})
It works perfectly!
Unable to understand what is the difference in the 2 approaches apart from syntax....