-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
ENH: Control resampling at halfyear with origin #60928
Comments
. |
Thanks for the report, I don't think the expectation is correct. It appears to me pandas consistently resamples based on the first observation. s = pd.Series(1, pd.date_range('2025-04-04', freq='D', periods=5))
print(s)
# 2025-04-02 1
# 2025-04-03 1
# 2025-04-04 1
# 2025-04-05 1
# 2025-04-06 1
print(s.resample('3D').sum())
# 2025-04-02 3
# 2025-04-05 2
# Freq: 3D, dtype: int64 As such, in your example, the first observation for You can control this for certain frequencies with |
@rhshadrach we currently have a |
Perhaps it's not a bad idea to add |
I'm positive on this, especially if it is a simple addition. |
take |
Thanks guy for this fast and constructive discussion. Very happy to see this get implemented; thanks @snitish for your contribution! |
@rwijtvliet you're welcome! However, please note - this change is still under review, so you might want to reopen the issue for tracking purposes (it'll be closed automatically after the PR is merged). |
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
It seems there is no way to force where the period boundaries are when resampling at the 2-Quarter frequency. Resampling at
2QS-APR
gives the same results fors1
ands2
as those shown above.Expected Behavior
I'd expect the index of
s2
to also have timestamps on the first of January and July.Installed Versions
pandas : 2.2.3
numpy : 1.26.4
pytz : 2024.2
dateutil : 2.9.0.post0
pip : 24.3.1
Cython : None
sphinx : 7.3.7
IPython : 8.29.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.4
lxml.etree : None
matplotlib : 3.9.2
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.5
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : None
pyreadstat : None
pytest : 8.3.3
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : 0.9.0
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2024.2
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: