Skip to content

BUG/REF: use sorted_rank_1d for rank_2d #41931

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

Merged
merged 27 commits into from
Jun 25, 2021
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c7a91ac
REF: split out sorted_rank algo
mzeitlin11 Jun 9, 2021
4b0641e
Fixup docstring
mzeitlin11 Jun 9, 2021
b6dd4a6
WIP
mzeitlin11 Jun 9, 2021
953b188
WIP
mzeitlin11 Jun 10, 2021
254b997
premerge
mzeitlin11 Jun 10, 2021
5602dca
Merge remote-tracking branch 'upstream/master' into ref/rank_2d_dedup
mzeitlin11 Jun 10, 2021
29dc590
REF: give ranks same nan filling
mzeitlin11 Jun 10, 2021
9abd9da
Merge branch 'rank_2d_dedup_chunk' into ref/rank_2d_dedup
mzeitlin11 Jun 10, 2021
974650d
WIP
mzeitlin11 Jun 10, 2021
b840b74
Handle empty case early
mzeitlin11 Jun 10, 2021
f099bb0
Handle empty case early
mzeitlin11 Jun 10, 2021
4aa4f8b
WIP
mzeitlin11 Jun 10, 2021
c5ed688
WIP
mzeitlin11 Jun 10, 2021
7a04159
Add object first test
mzeitlin11 Jun 10, 2021
ab9989e
Add back nogil
mzeitlin11 Jun 10, 2021
5ba6459
Add whatsnew
mzeitlin11 Jun 10, 2021
6154004
Cleaner fused type handling
mzeitlin11 Jun 10, 2021
d678bbf
Merge branch 'rank_2d_dedup_chunk' into ref/rank_2d_dedup
mzeitlin11 Jun 10, 2021
0f8744d
Add comment
mzeitlin11 Jun 10, 2021
d47f2a6
Update whatsnew
mzeitlin11 Jun 10, 2021
da61fb8
Try 32-bit fix
mzeitlin11 Jun 10, 2021
e2d9617
Debug 32-bit
mzeitlin11 Jun 10, 2021
b4d11a4
Debug 32-bit
mzeitlin11 Jun 11, 2021
9a94724
Merge remote-tracking branch 'upstream/master' into ref/rank_2d_dedup
mzeitlin11 Jun 17, 2021
1e47dae
Move whatsnew
mzeitlin11 Jun 17, 2021
4d72d93
Merge remote-tracking branch 'upstream/master' into ref/rank_2d_dedup
mzeitlin11 Jun 22, 2021
d7b398b
Merge remote-tracking branch 'upstream/master' into ref/rank_2d_dedup
mzeitlin11 Jun 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP
  • Loading branch information
mzeitlin11 committed Jun 10, 2021
commit c5ed688143a8ff9b278e473bad46b2140fb812bf
20 changes: 4 additions & 16 deletions pandas/tests/frame/methods/test_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,8 @@ def test_rank_methods_frame(self):
tm.assert_frame_equal(result, expected)

@pytest.mark.parametrize("dtype", ["O", "f8", "i8"])
@pytest.mark.parametrize("rank_method", ["average", "min", "max", "dense"])
@pytest.mark.filterwarnings("ignore:.*Select only valid:FutureWarning")
def test_rank_descending(self, rank_method, dtype):
def test_rank_descending(self, method, dtype):
if "i" in dtype:
df = self.df.dropna().astype(dtype)
else:
Expand All @@ -259,26 +258,15 @@ def test_rank_descending(self, rank_method, dtype):
expected = (df.max() - df).rank()
tm.assert_frame_equal(res, expected)

expected = (df.max() - df).rank(method=rank_method)
expected = (df.max() - df).rank(method=method)

if dtype != "O":
res2 = df.rank(method=rank_method, ascending=False, numeric_only=True)
res2 = df.rank(method=method, ascending=False, numeric_only=True)
tm.assert_frame_equal(res2, expected)

res3 = df.rank(method=rank_method, ascending=False, numeric_only=False)
res3 = df.rank(method=method, ascending=False, numeric_only=False)
tm.assert_frame_equal(res3, expected)

@pytest.mark.parametrize("dtype", ["O", "f8", "i8"])
@pytest.mark.parametrize("ascending", [True, False])
def test_rank_first_ties(self, dtype, ascending, frame_or_series):
obj = frame_or_series([1, 1], dtype=dtype)
result = obj.rank(method="first", ascending=ascending)
expected_data = [1, 2]
if ascending:
expected_data = expected_data[::-1]
expected = frame_or_series(expected_data, dtype=np.float64)
tm.assert_equal(result, expected)

@pytest.mark.parametrize("axis", [0, 1])
@pytest.mark.parametrize("dtype", [None, object])
def test_rank_2d_tie_methods(self, method, axis, dtype):
Expand Down