Description
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