-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: groupby then resample on column gives incorrect results if the index is out of order #59350
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
Open
2 of 3 tasks
Comments
take |
To solve this issue please Modify the DatetimeIndexResampler class in your resample.py located at "pandas/pandas/core /resample.py" here is the corrected code for the DatetimeIndexResampler
` |
Amit-0905
added a commit
to Amit-0905/pandas
that referenced
this issue
Jul 30, 2024
Update to solve :- BUG: groupby then resample on column gives incorrect results if the index is out of order pandas-dev#59350
Closed
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 example above gives the following incorrect output:
Expected Behavior
The correct output is:
The correct output can be got using either of the following - either reset the index, or use the datetime column as the index.
It seems the out-of-order index (
[1, 0]
instead of[0, 1]
) is affecting the resampling, even though the index should be ignored when using theon
keyword argument toresample
. This may be related to #35275 where it seems the index also affects the operation of resampling on a column (in that case giving an IndexError if the index value is not less than the length of the data frame.)Installed Versions
INSTALLED VERSIONS
commit : d9cdd2e
python : 3.9.15.final.0
python-bits : 64
OS : Linux
OS-release : 5.14.0-284.11.1.el9_2.x86_64
Version : #1 SMP PREEMPT_DYNAMIC Tue May 9 17:09:15 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : C.UTF-8
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.2.2
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.9.0.post0
setuptools : 70.3.0
pip : 24.0
Cython : 3.0.10
pytest : 8.2.2
hypothesis : 6.108.2
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 5.1.1
html5lib : None
pymysql : 1.4.6
psycopg2 : None
jinja2 : 3.1.4
IPython : 8.18.1
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : None
dataframe-api-compat : None
fastparquet : 2024.5.0
fsspec : 2024.6.1
gcsfs : None
matplotlib : 3.9.1
numba : 0.60.0
numexpr : 2.10.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.13.1
sqlalchemy : None
tables : 3.9.2
tabulate : 0.9.0
xarray : 2024.3.0
xlrd : 2.0.1
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: