Skip to content

Commit

Permalink
add test from original issue
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Oct 17, 2022
1 parent f60a87b commit b6bd617
Showing 1 changed file with 9 additions and 25 deletions.
34 changes: 9 additions & 25 deletions pandas/tests/frame/methods/test_cov_corr.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,30 +412,14 @@ def test_corrwith_kendall(self):

def test_corrwith_spearman_with_tied_data(self):
# GH#48826
df = DataFrame(
df1 = DataFrame(
{
"A": [2, 5, 8, 9],
"B": [2, np.nan, 8, 9],
"C": Series([2, np.nan, 8, 9], dtype="Int64"),
"D": [0, 1, 1, 0],
"E": [0, np.nan, 1, 0],
"F": Series([0, np.nan, 1, 0], dtype="Float64"),
"G": [False, True, True, False],
"H": Series([False, pd.NA, True, False], dtype="boolean"),
},
)
ser_list = [
Series([0, 1, 1, 0]),
Series([0.0, 1.0, 1.0, 0.0]),
Series([False, True, True, False]),
Series([0, pd.NA, 1, 0], dtype="Int64"),
Series([0, pd.NA, 1, 0], dtype="Float64"),
Series([False, pd.NA, True, False], dtype="boolean"),
]
expected = Series(
[0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0],
index=["A", "B", "C", "D", "E", "F", "G", "H"],
"A": [1, np.nan, 7, 8],
"B": [False, True, True, False],
"C": [10, 4, 9, 3],
}
)
for ser in ser_list:
result = df.corrwith(ser, method="spearman", numeric_only=False)
tm.assert_series_equal(result, expected)
df2 = df1[["B", "C"]]
result = (df1 + 1).corrwith(df2.B, method="spearman")
expected = Series([0.0, 1.0, 0.0], index=["A", "B", "C"])
tm.assert_series_equal(result, expected)

0 comments on commit b6bd617

Please sign in to comment.