diff --git a/pandas/_libs/tslibs/fields.pyx b/pandas/_libs/tslibs/fields.pyx index ff4fb4d635d17..76a77cc8c606a 100644 --- a/pandas/_libs/tslibs/fields.pyx +++ b/pandas/_libs/tslibs/fields.pyx @@ -246,15 +246,15 @@ def get_start_end_field( if freqstr: if freqstr == "C": raise ValueError(f"Custom business days is not supported by {field}") - is_business = freqstr[0] == "B" - + period_str = "".join([ + dt_char for dt_char in list(freqstr.split("-")[0]) if not dt_char.isdigit() + ]) + is_business = period_str.startswith("B") # YearBegin(), BYearBegin() use month = starting month of year. # QuarterBegin(), BQuarterBegin() use startingMonth = starting # month of year. Other offsets use month, startingMonth as ending # month of year. - - if (freqstr[0:2] in ["MS", "QS", "YS"]) or ( - freqstr[1:3] in ["MS", "QS", "YS"]): + if (period_str in ["MS", "QS", "YS"]): end_month = 12 if month_kw == 1 else month_kw - 1 start_month = month_kw else: