-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Description
To help pandas to get better traction in the Earth sciences, it would be awesome to add support for climatological "season" as a Time/Date Component of pandas.DatetimeIndex. Season comes up in geoscience at least as often as "quarter" does in finance.
The standard seasons (the ones worth adding a shortcut for) would be ['DJF', 'MAM', 'JJA', 'SON'], as labeled by the first letter of each month. These could be represented by integers (in a pinch) but string labels would be much more natural -- people talk about the season "JJA" (or "summer" in the Northern hemisphere), not "season 3".
Actually, this might be a nice show case for the brand new CategoricalBlock (#7217).
For reference, here is some vectorized code to do the calculation from month numbers:
SEASONS = np.array(['DJF', 'MAM', 'JJA', 'SON'])
month = np.arange(12) + 1
season = SEASONS[(month // 3) % 4]
print season (We actually already use this code to add "season" to xray, but I think this would be useful more broadly as well.)