Skip to content

CLN: remove usages of base_and_stride #34700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3491,7 +3491,7 @@ INVALID_FREQ_ERR_MSG = "Invalid frequency: {0}"
_offset_map = {}


cpdef base_and_stride(str freqstr):
cdef _base_and_stride(str freqstr):
"""
Return base freq and stride info from string representation

Expand All @@ -3502,7 +3502,7 @@ cpdef base_and_stride(str freqstr):

Examples
--------
_freq_and_stride('5Min') -> 'Min', 5
_base_and_stride('5Min') -> 'Min', 5
"""
groups = opattern.match(freqstr)

Expand Down Expand Up @@ -3606,7 +3606,7 @@ cpdef to_offset(freq):
stride = freq[1]
if isinstance(stride, str):
name, stride = stride, name
name, _ = base_and_stride(name)
name, _ = _base_and_stride(name)
delta = _get_offset(name) * stride

elif isinstance(freq, timedelta):
Expand Down
4 changes: 1 addition & 3 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
conversion,
fields,
iNaT,
offsets as liboffsets,
resolution as libresolution,
timezones,
to_offset,
Expand Down Expand Up @@ -1106,8 +1105,7 @@ def to_period(self, freq=None):

# https://github.com/pandas-dev/pandas/issues/33358
if res is None:
base, stride = liboffsets.base_and_stride(freq)
res = f"{stride}{base}"
res = freq

freq = res

Expand Down
8 changes: 2 additions & 6 deletions pandas/plotting/_matplotlib/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from pandas._libs.tslibs import Period, to_offset
from pandas._libs.tslibs.frequencies import FreqGroup
from pandas._libs.tslibs.offsets import base_and_stride
from pandas._typing import FrameOrSeriesUnion

from pandas.core.dtypes.generic import (
Expand Down Expand Up @@ -167,12 +166,9 @@ def _get_ax_freq(ax):


def _get_period_alias(freq) -> Optional[str]:
if isinstance(freq, DateOffset):
freq = freq.rule_code
else:
freq = base_and_stride(freq)[0]
freqstr = to_offset(freq).rule_code

freq = get_period_alias(freq)
freq = get_period_alias(freqstr)
return freq


Expand Down