-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: pd.period_range
ignores multiple of start
frequency
#47465
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
Comments
Thanks @jaheba for the report.
from the docs...
So this does indeed appear to be a bug. start = pd.Period("2020", freq="3D")
print(pd.period_range(start, periods=2))
# PeriodIndex(['2020-01-01', '2020-01-02'], dtype='period[3D]')
print(b.freq)
# <3 * Days> Note : the but should be consistent with specifying the start = pd.Period("2020", freq="3D")
print(start.freq)
<3 * Days>
print(pd.period_range(start, periods=2, freq=start.freq))
# PeriodIndex(['2020-01-01', '2020-01-04'], dtype='period[3D]') contributions and PRs welcome. |
Thanks @simonjayhawkins -- I have submitted a PR: #47598 |
I think, PR #53709 closes this issue. |
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
Issue Description
The issue lies in
_get_ordinal_range
:pandas/pandas/core/arrays/period.py
Lines 1044 to 1089 in 37d4c31
A fix could be to replace:
pandas/pandas/core/arrays/period.py
Lines 1068 to 1072 in 37d4c31
with
Expected Behavior
Omitting the
freq
argument ofpd.period_range
should be the same as passing thefreq
of the start or end field to it viafreq=
.Installed Versions
Not relevant to issue.
The text was updated successfully, but these errors were encountered: