title: This function (season) takes too much time to run, why ? and how can I improve the code?
body: <p>This function (season) takes too much time to run, why ? and how can I improve the code ?</p>
  <h1>this is the function</h1>
  <pre><code>def season_of_date(date):
      date=pd.to_datetime(date)
      x=date.year
      year = str(x)
      seasons = {'spring': pd.date_range(start='21/03/'+year, end='20/06/'+year),
                 'summer': pd.date_range(start='21/06/'+year, end='22/09/'+year),
                 'autumn': pd.date_range(start='23/09/'+year, end='20/12/'+year)}
      if date in seasons['spring']:
          return 'spring'
      if date in seasons['summer']:
          return 'summer'
      if date in seasons['autumn']:
          return 'autumn'
      else:
          return 'winter'
  
  #I applied it to my dataset named dat
  data['season'] = data.DateTime.map(season_of_date)
  </code></pre>