[Scipy-svn] r2830 - trunk/Lib/sandbox/timeseries
scipy-svn at scipy.org
scipy-svn at scipy.org
Tue Mar 6 16:10:26 EST 2007
Author: mattknox_ca
Date: 2007-03-06 15:10:23 -0600 (Tue, 06 Mar 2007)
New Revision: 2830
Modified:
trunk/Lib/sandbox/timeseries/tcore.py
Log:
added support for new annual frequencies
Modified: trunk/Lib/sandbox/timeseries/tcore.py
===================================================================
--- trunk/Lib/sandbox/timeseries/tcore.py 2007-03-06 21:09:33 UTC (rev 2829)
+++ trunk/Lib/sandbox/timeseries/tcore.py 2007-03-06 21:10:23 UTC (rev 2830)
@@ -104,8 +104,31 @@
result += [pr+'-'+day_str for day_str in (day[:3], day)]
return result
-freq_dict = { FR_ANN: ['A','Y','ANNUAL','ANNUALLY','YEAR','YEARLY'],
- FR_QTR: ['Q','QUARTER','QUARTERLY',],
+_annual_prefixes = ['A','Y','ANNUAL','ANNUALLY','YEAR','YEARLY']
+_year_end_map = {
+ FR_ANNJAN:'JANUARY',
+ FR_ANNFEB:'FEBRUARY',
+ FR_ANNMAR:'MARCH',
+ FR_ANNAPR:'APRIL',
+ FR_ANNMAY:'MAY',
+ FR_ANNJUN:'JUNE',
+ FR_ANNJUL:'JULY',
+ FR_ANNAUG:'AUGUST',
+ FR_ANNSEP:'SEPTEMBER',
+ FR_ANNOCT:'OCTOBER',
+ FR_ANNNOV:'NOVEMBER',
+ FR_ANNDEC:'DECEMBER'
+ }
+
+def _gen_annual_strs(month):
+ result = []
+ for pr in _annual_prefixes:
+ result += [pr+'-'+mth_str for mth_str in (month[:3], month)]
+ return result
+
+
+
+freq_dict = { FR_QTR: ['Q','QUARTER','QUARTERLY',],
FR_MTH: ['M','MONTH','MONTHLY',],
FR_BUS: ['B','BUSINESS','BUSINESSLY'],
FR_DAY: ['D','DAY','DAILY',],
@@ -118,7 +141,11 @@
for _freq, day_str in _week_end_map.iteritems():
freq_dict[_freq] = _gen_weekly_strs(day_str)
freq_dict[FR_WK] += _weekly_prefixes
-
+
+for _freq, mth_str in _year_end_map.iteritems():
+ freq_dict[_freq] = _gen_annual_strs(mth_str)
+freq_dict[FR_ANN] += _annual_prefixes
+
freq_revdict = reverse_dict(freq_dict)
def freq_fromstr(freq_asstr):
More information about the Scipy-svn
mailing list