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
times = pd.date_range('1901-01-01', '1902-12-31', freq='D')
s = pd.Series(list(range(len(times))), times)
grouper = pd.Grouper(freq='2QS-OCT')
s.groupby(grouper).first()
# 1901-01-01 0
# 1901-07-01 181
# 1902-01-01 365
# 1902-07-01 546
# Freq: 2QS-OCT, dtype: int64
Issue Description
The Grouper
above was created with a frequency 2 quarters anchored in october. However, the first dates of each found groups do not correspond to that frequency. Rather, they seem to reflect a "2QS-JAN" or "2QS-JUL" frequency.
At first, I though that the issue was with rollback
and opened issue #48448, but it doesn't seem that this is the issue, as rollback
is acting as expected.
Expected Behavior
I expected the output to be:
1900-10-01 0
1901-04-01 90
1901-10-01 273
1902-04-01 455
1902-10-01 638
Freq: 2QS-OCT, dtype: int64
Where each group label actually correspond to the requested frequency.
Installed Versions
INSTALLED VERSIONS
commit : 2e218d1
python : 3.10.9.final.0
python-bits : 64
OS : Linux
OS-release : 6.1.11-100.fc36.x86_64
Version : #1 SMP PREEMPT_DYNAMIC Thu Feb 9 20:36:30 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : fr_CA.UTF-8
LOCALE : fr_CA.UTF-8
pandas : 1.5.3
numpy : 1.23.5
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 58.5.3
pip : 23.0.1
Cython : None
pytest : 7.2.1
hypothesis : None
sphinx : 6.1.3
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.10.0
pandas_datareader: None
bs4 : 4.11.2
bottleneck : 1.3.6
brotli :
fastparquet : None
fsspec : 2023.1.0
gcsfs : None
matplotlib : 3.7.0
numba : 0.56.4
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.8.1
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : 2023.2.0
xlrd : None
xlwt : None
zstandard : None
tzdata : Non