Closed
Description
Pandas version checks
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
index = pd.PeriodIndex(["2020-01-01", "2021-01-01"], freq="M")
df = pd.DataFrame({"a": pd.Series([0, 1], index=index)})
print(df.index)
expected = df.asfreq(freq="2MS")
Issue Description
In this case we get
AttributeError: 'pandas._libs.tslibs.offsets.MonthBegin' object has no attribute '_period_dtype_code'
Expected Behavior
the expected message should be
TypeError: MS is not supported as period frequency
Installed Versions
Replace this line with the output of pd.show_versions()