as input there is an array with numbers from 1 to 12. At the output, I want to get an array that will produce, depending on the number, the time of year
import pandas as pd
month = pd.Series([i for i in range(1,13)])
def mkseason(n):
if 3<=n<=5: season = 'spring'
elif 6<=n<=8: season = 'summer'
elif 9<=n<=11: season = 'fall'
elif n<=2 or n==12: season = 'winter'
else: season = 'unknown'
return(season)
As result I want to get array -
['winter','winter','spring','spring','spring','summer','summer','summer','fall','fall','fall','winter']
When I tried make something like this:
mkseason(month)
I have gor an error. How should I solve my problem? I need to use pandas without loops