@@ -36,12 +36,7 @@ from tslib cimport (
36
36
_nat_scalar_rules,
37
37
)
38
38
39
- from pandas.tseries.frequencies import _period_alias_dict
40
- from pandas.tseries.frequencies import _get_freq_str
41
- from pandas.tseries.frequencies import to_offset
42
- from pandas.tseries.frequencies import get_freq_code as _gfc
43
39
from pandas.tseries import frequencies
44
- from pandas.tseries.constants import US_RESO, MS_RESO, S_RESO, T_RESO, H_RESO, D_RESO
45
40
46
41
from sys import version_info
47
42
@@ -468,7 +463,7 @@ cpdef resolution(ndarray[int64_t] stamps, tz=None):
468
463
cdef:
469
464
Py_ssize_t i, n = len (stamps)
470
465
pandas_datetimestruct dts
471
- int reso = D_RESO, curr_reso
466
+ int reso = frequencies. D_RESO, curr_reso
472
467
473
468
if tz is not None :
474
469
tz = maybe_get_tz(tz)
@@ -487,20 +482,20 @@ cpdef resolution(ndarray[int64_t] stamps, tz=None):
487
482
cdef inline int _reso_stamp(pandas_datetimestruct * dts):
488
483
if dts.us != 0 :
489
484
if dts.us % 1000 == 0 :
490
- return MS_RESO
491
- return US_RESO
485
+ return frequencies. MS_RESO
486
+ return frequencies. US_RESO
492
487
elif dts.sec != 0 :
493
- return S_RESO
488
+ return frequencies. S_RESO
494
489
elif dts.min != 0 :
495
- return T_RESO
490
+ return frequencies. T_RESO
496
491
elif dts.hour != 0 :
497
- return H_RESO
498
- return D_RESO
492
+ return frequencies. H_RESO
493
+ return frequencies. D_RESO
499
494
500
495
cdef _reso_local(ndarray[int64_t] stamps, object tz):
501
496
cdef:
502
497
Py_ssize_t n = len (stamps)
503
- int reso = D_RESO, curr_reso
498
+ int reso = frequencies. D_RESO, curr_reso
504
499
ndarray[int64_t] trans, deltas, pos
505
500
pandas_datetimestruct dts
506
501
@@ -664,12 +659,12 @@ cdef class Period(object):
664
659
665
660
if isinstance (freq, compat.string_types):
666
661
freq = freq.upper()
667
- freq = _period_alias_dict.get(freq, freq)
662
+ freq = frequencies. _period_alias_dict.get(freq, freq)
668
663
elif isinstance (freq, (int , tuple )):
669
- code, stride = _gfc (freq)
670
- freq = _get_freq_str(code, stride)
664
+ code, stride = frequencies.get_freq_code (freq)
665
+ freq = frequencies. _get_freq_str(code, stride)
671
666
672
- freq = to_offset(freq)
667
+ freq = frequencies. to_offset(freq)
673
668
674
669
if freq.n <= 0 :
675
670
raise ValueError (' Frequency must be positive, because it'
@@ -711,7 +706,7 @@ cdef class Period(object):
711
706
712
707
elif isinstance (value, Period):
713
708
other = value
714
- if freq is None or _gfc (freq) == _gfc (other.freq):
709
+ if freq is None or frequencies.get_freq_code (freq) == frequencies.get_freq_code (other.freq):
715
710
ordinal = other.ordinal
716
711
freq = other.freq
717
712
else :
@@ -752,7 +747,7 @@ cdef class Period(object):
752
747
msg = " Value must be Period, string, integer, or datetime"
753
748
raise ValueError (msg)
754
749
755
- base, mult = _gfc (freq)
750
+ base, mult = frequencies.get_freq_code (freq)
756
751
757
752
if ordinal is None :
758
753
self .ordinal = get_period_ordinal(dt.year, dt.month, dt.day,
@@ -861,8 +856,8 @@ cdef class Period(object):
861
856
resampled : Period
862
857
"""
863
858
how = _validate_end_alias(how)
864
- base1, mult1 = _gfc (self .freq)
865
- base2, mult2 = _gfc (freq)
859
+ base1, mult1 = frequencies.get_freq_code (self .freq)
860
+ base2, mult2 = frequencies.get_freq_code (freq)
866
861
867
862
if self .ordinal == tslib.iNaT:
868
863
ordinal = self .ordinal
@@ -912,17 +907,17 @@ cdef class Period(object):
912
907
how = _validate_end_alias(how)
913
908
914
909
if freq is None :
915
- base, mult = _gfc (self .freq)
910
+ base, mult = frequencies.get_freq_code (self .freq)
916
911
freq = frequencies.get_to_timestamp_base(base)
917
912
918
- base, mult = _gfc (freq)
913
+ base, mult = frequencies.get_freq_code (freq)
919
914
val = self .asfreq(freq, how)
920
915
921
916
dt64 = period_ordinal_to_dt64(val.ordinal, base)
922
917
return Timestamp(dt64, tz = tz)
923
918
924
919
cdef _field(self , alias):
925
- base, mult = _gfc (self .freq)
920
+ base, mult = frequencies.get_freq_code (self .freq)
926
921
return get_period_field(alias, self .ordinal, base)
927
922
928
923
property year :
@@ -984,7 +979,7 @@ cdef class Period(object):
984
979
return self .freq.freqstr
985
980
986
981
def __repr__ (self ):
987
- base, mult = _gfc (self .freq)
982
+ base, mult = frequencies.get_freq_code (self .freq)
988
983
formatted = period_format(self .ordinal, base)
989
984
return " Period('%s ', '%s ')" % (formatted, self .freqstr)
990
985
@@ -995,7 +990,7 @@ cdef class Period(object):
995
990
Invoked by unicode(df) in py2 only. Yields a Unicode String in both
996
991
py2/py3.
997
992
"""
998
- base, mult = _gfc (self .freq)
993
+ base, mult = frequencies.get_freq_code (self .freq)
999
994
formatted = period_format(self .ordinal, base)
1000
995
value = (" %s " % formatted)
1001
996
return value
@@ -1145,13 +1140,13 @@ cdef class Period(object):
1145
1140
>>> a.strftime('%b . %d , %Y was a %A ')
1146
1141
'Jan. 01, 2001 was a Monday'
1147
1142
"""
1148
- base, mult = _gfc (self .freq)
1143
+ base, mult = frequencies.get_freq_code (self .freq)
1149
1144
return period_format(self .ordinal, base, fmt)
1150
1145
1151
1146
1152
1147
def _ordinal_from_fields (year , month , quarter , day , hour , minute ,
1153
1148
second , freq ):
1154
- base, mult = _gfc (freq)
1149
+ base, mult = frequencies.get_freq_code (freq)
1155
1150
if quarter is not None :
1156
1151
year, month = _quarter_to_myear(year, quarter, freq)
1157
1152
0 commit comments