Skip to content

Commit f691711

Browse files
TomAugspurgerjreback
authored andcommitted
PERF: Speeds up creation of Period, PeriodArray, with Offset freq (#23589)
1 parent 700520d commit f691711

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

pandas/_libs/tslibs/offsets.pyx

+2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ cdef to_offset(object obj):
8484
Wrap pandas.tseries.frequencies.to_offset to keep centralize runtime
8585
imports
8686
"""
87+
if isinstance(obj, _BaseOffset):
88+
return obj
8789
from pandas.tseries.frequencies import to_offset
8890
return to_offset(obj)
8991

pandas/_libs/tslibs/period.pyx

-1
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,6 @@ cdef class _Period(object):
15671567

15681568
@classmethod
15691569
def _maybe_convert_freq(cls, object freq):
1570-
15711570
if isinstance(freq, (int, tuple)):
15721571
code, stride = get_freq_code(freq)
15731572
freq = get_freq_str(code, stride)

0 commit comments

Comments
 (0)