Skip to content

Commit

Permalink
PERF: Speeds up creation of Period, PeriodArray, with Offset freq (#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAugspurger authored and jreback committed Nov 9, 2018
1 parent 700520d commit f691711
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ cdef to_offset(object obj):
Wrap pandas.tseries.frequencies.to_offset to keep centralize runtime
imports
"""
if isinstance(obj, _BaseOffset):
return obj
from pandas.tseries.frequencies import to_offset
return to_offset(obj)

Expand Down
1 change: 0 additions & 1 deletion pandas/_libs/tslibs/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,6 @@ cdef class _Period(object):

@classmethod
def _maybe_convert_freq(cls, object freq):

if isinstance(freq, (int, tuple)):
code, stride = get_freq_code(freq)
freq = get_freq_str(code, stride)
Expand Down

0 comments on commit f691711

Please sign in to comment.