6
6
import numpy as np
7
7
import pytest
8
8
9
- from pandas ._config import using_string_dtype
10
-
11
9
from pandas ._libs .algos import (
12
10
Infinity ,
13
11
NegInfinity ,
14
12
)
15
- from pandas .compat import HAS_PYARROW
16
13
17
- import pandas as pd
18
14
from pandas import (
19
15
DataFrame ,
20
16
Index ,
@@ -467,23 +463,10 @@ def test_rank_inf_nans_na_option(
467
463
("top" , False , [2.0 , 3.0 , 1.0 , 4.0 ]),
468
464
],
469
465
)
470
- def test_rank_object_first (
471
- self ,
472
- request ,
473
- frame_or_series ,
474
- na_option ,
475
- ascending ,
476
- expected ,
477
- using_infer_string ,
478
- ):
466
+ def test_rank_object_first (self , frame_or_series , na_option , ascending , expected ):
479
467
obj = frame_or_series (["foo" , "foo" , None , "foo" ])
480
- if using_string_dtype () and not HAS_PYARROW and isinstance (obj , Series ):
481
- request .applymarker (pytest .mark .xfail (reason = "TODO(infer_string)" ))
482
-
483
468
result = obj .rank (method = "first" , na_option = na_option , ascending = ascending )
484
469
expected = frame_or_series (expected )
485
- if using_infer_string and isinstance (obj , Series ):
486
- expected = expected .astype ("uint64" )
487
470
tm .assert_equal (result , expected )
488
471
489
472
@pytest .mark .parametrize (
@@ -507,7 +490,9 @@ def test_rank_string_dtype(self, string_dtype_no_object):
507
490
# GH#55362
508
491
obj = Series (["foo" , "foo" , None , "foo" ], dtype = string_dtype_no_object )
509
492
result = obj .rank (method = "first" )
510
- exp_dtype = "Int64" if string_dtype_no_object .na_value is pd .NA else "float64"
493
+ exp_dtype = (
494
+ "Float64" if string_dtype_no_object == "string[pyarrow]" else "float64"
495
+ )
511
496
if string_dtype_no_object .storage == "python" :
512
497
# TODO nullable string[python] should also return nullable Int64
513
498
exp_dtype = "float64"
0 commit comments