From 7fb7c1920565d3dce707b2da5a0cc43db96f47a9 Mon Sep 17 00:00:00 2001 From: Brock Date: Sat, 6 Jun 2020 09:17:54 -0700 Subject: [PATCH] DOC: docstring, closes #23475 --- pandas/_libs/tslibs/period.pyx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pandas/_libs/tslibs/period.pyx b/pandas/_libs/tslibs/period.pyx index e88a20bc549bd..5c890c7fbf59d 100644 --- a/pandas/_libs/tslibs/period.pyx +++ b/pandas/_libs/tslibs/period.pyx @@ -1529,7 +1529,16 @@ cdef class _Period: self._dtype = PeriodPseudoDtype(freq._period_dtype_code) @classmethod - def _maybe_convert_freq(cls, object freq): + def _maybe_convert_freq(cls, object freq) -> BaseOffset: + """ + Internally we allow integer and tuple representations (for now) that + are not recognized by to_offset, so we convert them here. Also, a + Period's freq attribute must have `freq.n > 0`, which we check for here. + + Returns + ------- + DateOffset + """ if isinstance(freq, (int, tuple)): code, stride = get_freq_code(freq) freq = get_freq_str(code, stride)