-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DataFrame.corr(method="spearman") much slower than DataFrame.rank().corr(method="pearson") #28139
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
Any chance you can profile to see where the overhead is? I think both are cythonized in pandas._libs.algos.pyx so surprised to see such a difference |
Here's the truncated output for both:
Looks like pretty much all the time is spent in the Cythonized |
@WillAyd Not sure if this would fully explain it, but it looks to me like we're ranking the columns inside a nested for loop within |
Not overly familiar with this code but a quick glance I think your inclination is correct. Probably a more efficient way to do it once outside the loop and handled accordingly within. If you've got a way to make it work would certainly take a PR |
Uh oh!
There was an error while loading. Please reload this page.
Problem description
DataFrame.corr(method="spearman")
seems to be an order of magnitude slower thanDataFrame.rank().corr(method="pearson")
even though the two are ultimately doing the same calculation. While probably not the cleanest option, I would think thatcorr(method="spearman")
could at least be made an alias forrank().corr(method="pearson")
, or maybe a change could be made inalgos.pyx
.Output of
pd.show_versions()
pandas : 0.25.0
numpy : 1.16.4
pytz : 2019.1
dateutil : 2.8.0
pip : 19.1.1
setuptools : 41.0.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.10.1
IPython : 7.5.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.1.0
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.3.0
sqlalchemy : None
tables : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
The text was updated successfully, but these errors were encountered: