-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: RollingGroupby.corr() producing incorrect results #43386
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
Comments
Thanks @grantgustafson for the report. can you update the code sample with a minimum reproducible example https://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports AFAICT with just a quick look the problem is maybe with the rolling step. code sample (not yet minimal) with some "debug"
|
first bad commit: [b2671cc] PERF: Rolling/Expanding.cov/corr (#39591) cc @mroeschke also xref #42915 which is a grouping issue. |
Hi @simonjayhawkins, my example is as minimum of a repro that I can currently produce. Since it requires multiple groups and a rolling window, I hit a soft-floor. I don't doubt it can be made more concise though. |
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Problem description
This RollingGroupby.corr() operation is producing incorrect results. The example above shows how sorting the dataframe with respect to the groupby key fixes the issue, but that should not be necessary since it is the groupby key. I have tested and this bug does not exist in version
1.2.5
. It first appears in1.3.0
.Expected Output
The bottom part of the above repro contains expected output. Here's another way of showing expected output by filtering to one group:
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 5f648bf
python : 3.8.10.final.0
python-bits : 64
OS : Linux
OS-release : 4.18.0-240.22.1.el8_3.x86_64
Version : #1 SMP Thu Mar 25 14:36:04 EDT 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.3.2
numpy : 1.21.2
pytz : 2021.1
dateutil : 2.8.2
pip : 21.2.4
setuptools : 57.4.0
Cython : None
pytest : 6.2.5
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.1
IPython : 7.27.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : 0.8.7
fastparquet : None
gcsfs : None
matplotlib : 3.4.3
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 5.0.0
pyxlsb : None
s3fs : 0.4.2
scipy : 1.7.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : 2.0.1
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: