-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
REG: fix regression in df.corrwith on tied data when method is spearman #49032
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
Changes from 5 commits
d228d7b
e230225
059effd
6a898f0
8fd679d
3528e40
12e9232
8578581
93879df
8ae9403
2f3c952
cef9e9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10598,18 +10598,23 @@ def corrwith( | |
cols = self.columns | ||
ndf = self.values.transpose() | ||
k = other.values | ||
k_mask = ~np.isnan(k) | ||
if k.dtype == "bool": | ||
k = k.astype("float") | ||
|
||
if method == "pearson": | ||
for i, r in enumerate(ndf): | ||
nonnull_mask = ~np.isnan(r) & ~np.isnan(k) | ||
nonnull_mask = ~np.isnan(r) & k_mask | ||
corrs[cols[i]] = np.corrcoef(r[nonnull_mask], k[nonnull_mask])[ | ||
0, 1 | ||
] | ||
else: | ||
for i, r in enumerate(ndf): | ||
nonnull_mask = ~np.isnan(r) & ~np.isnan(k) | ||
nonnull_mask = ~np.isnan(r) & k_mask | ||
if r.dtype == "bool": | ||
r = r.astype("float") | ||
corrs[cols[i]] = np.corrcoef( | ||
r[nonnull_mask].argsort().argsort(), | ||
k[nonnull_mask].argsort().argsort(), | ||
libalgos.rank_1d(r[nonnull_mask]), | ||
libalgos.rank_1d(k[nonnull_mask]), | ||
)[0, 1] | ||
return Series(corrs) | ||
else: | ||
|
Uh oh!
There was an error while loading. Please reload this page.