Skip to content

loffset in pd.Grouper does not apply #29161

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

Closed
hrm13 opened this issue Oct 22, 2019 · 2 comments
Closed

loffset in pd.Grouper does not apply #29161

hrm13 opened this issue Oct 22, 2019 · 2 comments
Labels
Duplicate Report Duplicate issue or pull request

Comments

@hrm13
Copy link

hrm13 commented Oct 22, 2019

Code Sample

date_index = pd.date_range("2019-08-26", "2019-09-20")
sessions = DataFrame(range(1, len(dates) + 1), index=date_index, columns=['foo'])

sessions.groupby(pd.Grouper(freq=pd.Timedelta(weeks=4), key='created_at', loffset='4W')).size()

Problem description

The above use of loffset does not change the grouping labels as expected. The corresponding code using DataFrame.resample does work. Try:

sessions.resample(pd.Timedelta(weeks=4), on='created_at', loffset='4W')

Expected Output

created_at
2019-09-22    1048
2019-10-20     904
Freq: 28D, dtype: int64

Actual Output

created_at
2019-08-26    1048
2019-09-23     904
Freq: 28D, dtype: int64

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.6.4.final.0
python-bits : 64
OS : Darwin
OS-release : 18.6.0
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8

pandas : 0.25.2
numpy : 1.16.2
pytz : 2018.9
dateutil : 2.8.0
pip : 9.0.1
setuptools : 28.8.0
Cython : None
pytest : 4.6.5
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 1.1.1
lxml.etree : 4.3.2
html5lib : None
pymysql : 0.9.3
psycopg2 : None
jinja2 : 2.10
IPython : 7.5.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.3.2
matplotlib : 3.0.0
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.2.1
sqlalchemy : 1.2.12
tables : None
xarray : None
xlrd : 1.2.0
xlwt : None
xlsxwriter : 1.1.1

@hwalinga
Copy link
Contributor

Seems to be the same as #28302

@mroeschke
Copy link
Member

Closing as a duplicate of #28302

@mroeschke mroeschke added the Duplicate Report Duplicate issue or pull request label Oct 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request
Projects
None yet
Development

No branches or pull requests

3 participants