1
1
import numpy as np
2
2
from numpy cimport ndarray, int64_t, int32_t
3
3
4
- from pandas._libs.tslibs.util cimport get_nat, is_offset_object
4
+ from pandas._libs.tslibs.util cimport get_nat
5
5
6
6
from pandas._libs.tslibs.np_datetime cimport (
7
7
npy_datetimestruct, dt64_to_dtstruct)
8
- from pandas._libs.tslibs.frequencies cimport get_freq_code
8
+ from pandas._libs.tslibs.frequencies cimport attrname_to_abbrevs
9
9
from pandas._libs.tslibs.timezones cimport (
10
10
is_utc, is_tzlocal, maybe_get_tz, get_dst_info)
11
11
from pandas._libs.tslibs.ccalendar cimport get_days_in_month
25
25
int RESO_HR = 5
26
26
int RESO_DAY = 6
27
27
28
+
28
29
# ----------------------------------------------------------------------
29
30
30
31
cpdef resolution(const int64_t[:] stamps, tz = None ):
@@ -106,31 +107,6 @@ cdef inline int _reso_stamp(npy_datetimestruct *dts):
106
107
return RESO_DAY
107
108
108
109
109
- def get_freq_group (freq ) -> int:
110
- """
111
- Return frequency code group of given frequency str or offset.
112
-
113
- Examples
114
- --------
115
- >>> get_freq_group('W-MON')
116
- 4000
117
-
118
- >>> get_freq_group('W-FRI')
119
- 4000
120
- """
121
- if is_offset_object(freq ):
122
- freq = freq.rule_code
123
-
124
- if isinstance (freq, str ):
125
- base, mult = get_freq_code(freq)
126
- freq = base
127
- elif isinstance (freq, int ):
128
- pass
129
- else :
130
- raise ValueError (' input must be str, offset or int' )
131
- return (freq // 1000 ) * 1000
132
-
133
-
134
110
class Resolution :
135
111
136
112
# Note: cython won't allow us to reference the cdef versions at the
@@ -163,7 +139,7 @@ class Resolution:
163
139
RESO_HR: 60 ,
164
140
RESO_DAY: 24 }
165
141
166
- _reso_str_bump_map = {
142
+ reso_str_bump_map = {
167
143
' D' : ' H' ,
168
144
' H' : ' T' ,
169
145
' T' : ' S' ,
@@ -174,19 +150,7 @@ class Resolution:
174
150
175
151
_str_reso_map = {v: k for k, v in _reso_str_map.items()}
176
152
177
- _reso_freq_map = {
178
- ' year' : ' A' ,
179
- ' quarter' : ' Q' ,
180
- ' month' : ' M' ,
181
- ' day' : ' D' ,
182
- ' hour' : ' H' ,
183
- ' minute' : ' T' ,
184
- ' second' : ' S' ,
185
- ' millisecond' : ' L' ,
186
- ' microsecond' : ' U' ,
187
- ' nanosecond' : ' N' }
188
-
189
- _freq_reso_map = {v: k for k, v in _reso_freq_map.items()}
153
+ _freq_reso_map = {v: k for k, v in attrname_to_abbrevs.items()}
190
154
191
155
@classmethod
192
156
def get_str (cls , reso: int ) -> str:
@@ -215,30 +179,6 @@ class Resolution:
215
179
"""
216
180
return cls._str_reso_map.get(resostr , cls.RESO_DAY )
217
181
218
- @classmethod
219
- def get_freq_group(cls , resostr: str ) -> int:
220
- """
221
- Return frequency str against resolution str.
222
-
223
- Examples
224
- --------
225
- >>> f.Resolution.get_freq_group('day')
226
- 4000
227
- """
228
- return get_freq_group(cls.get_freq(resostr ))
229
-
230
- @classmethod
231
- def get_freq(cls , resostr: str ) -> str:
232
- """
233
- Return frequency str against resolution str.
234
-
235
- Examples
236
- --------
237
- >>> f.Resolution.get_freq('day')
238
- 'D'
239
- """
240
- return cls._reso_freq_map[resostr]
241
-
242
182
@classmethod
243
183
def get_str_from_freq(cls , freq: str ) -> str:
244
184
"""
@@ -303,7 +243,7 @@ class Resolution:
303
243
)
304
244
305
245
next_value = cls ._reso_mult_map[start_reso] * value
306
- next_name = cls ._reso_str_bump_map [freq]
246
+ next_name = cls .reso_str_bump_map [freq]
307
247
return cls .get_stride_from_decimal(next_value, next_name)
308
248
309
249
0 commit comments