@@ -1246,6 +1246,7 @@ def test_idxminmax_object_dtype(self, using_infer_string):
1246
1246
with pytest .raises (TypeError , match = msg ):
1247
1247
ser3 .idxmin (skipna = False )
1248
1248
1249
+ # TODO(infer_string) implement argmin/max for python string dtype
1249
1250
@pytest .mark .xfail (
1250
1251
using_string_dtype () and not HAS_PYARROW , reason = "TODO(infer_string)"
1251
1252
)
@@ -1485,12 +1486,14 @@ def test_mode_numerical_nan(self, dropna, expected):
1485
1486
expected = Series (expected )
1486
1487
tm .assert_series_equal (result , expected )
1487
1488
1488
- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
1489
1489
@pytest .mark .parametrize (
1490
- "dropna, expected1, expected2, expected3" ,
1491
- [(True , ["b" ], ["bar" ], ["nan" ]), (False , ["b" ], [np .nan ], ["nan" ])],
1490
+ "dropna, expected1, expected2" ,
1491
+ [
1492
+ (True , ["b" ], ["bar" ]),
1493
+ (False , ["b" ], [np .nan ]),
1494
+ ],
1492
1495
)
1493
- def test_mode_str_obj (self , dropna , expected1 , expected2 , expected3 ):
1496
+ def test_mode_object (self , dropna , expected1 , expected2 ):
1494
1497
# Test string and object types.
1495
1498
data = ["a" ] * 2 + ["b" ] * 3
1496
1499
@@ -1503,30 +1506,45 @@ def test_mode_str_obj(self, dropna, expected1, expected2, expected3):
1503
1506
1504
1507
s = Series (data , dtype = object )
1505
1508
result = s .mode (dropna )
1506
- expected2 = Series (expected2 , dtype = None if expected2 == [ "bar" ] else object )
1509
+ expected2 = Series (expected2 , dtype = object )
1507
1510
tm .assert_series_equal (result , expected2 )
1508
1511
1512
+ @pytest .mark .parametrize (
1513
+ "dropna, expected1, expected2" ,
1514
+ [
1515
+ (True , ["b" ], ["bar" ]),
1516
+ (False , ["b" ], [np .nan ]),
1517
+ ],
1518
+ )
1519
+ def test_mode_string (self , dropna , expected1 , expected2 , any_string_dtype ):
1520
+ # Test string and object types.
1521
+ data = ["a" ] * 2 + ["b" ] * 3
1522
+
1523
+ s = Series (data , dtype = any_string_dtype )
1524
+ result = s .mode (dropna )
1525
+ expected1 = Series (expected1 , dtype = any_string_dtype )
1526
+ tm .assert_series_equal (result , expected1 )
1527
+
1509
1528
data = ["foo" , "bar" , "bar" , np .nan , np .nan , np .nan ]
1510
1529
1511
- s = Series (data , dtype = object ). astype ( str )
1530
+ s = Series (data , dtype = any_string_dtype )
1512
1531
result = s .mode (dropna )
1513
- expected3 = Series (expected3 )
1514
- tm .assert_series_equal (result , expected3 )
1532
+ expected2 = Series (expected2 , dtype = any_string_dtype )
1533
+ tm .assert_series_equal (result , expected2 )
1515
1534
1516
- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
1517
1535
@pytest .mark .parametrize (
1518
1536
"dropna, expected1, expected2" ,
1519
1537
[(True , ["foo" ], ["foo" ]), (False , ["foo" ], [np .nan ])],
1520
1538
)
1521
1539
def test_mode_mixeddtype (self , dropna , expected1 , expected2 ):
1522
1540
s = Series ([1 , "foo" , "foo" ])
1523
1541
result = s .mode (dropna )
1524
- expected = Series (expected1 )
1542
+ expected = Series (expected1 , dtype = object )
1525
1543
tm .assert_series_equal (result , expected )
1526
1544
1527
1545
s = Series ([1 , "foo" , "foo" , np .nan , np .nan , np .nan ])
1528
1546
result = s .mode (dropna )
1529
- expected = Series (expected2 , dtype = None if expected2 == [ "foo" ] else object )
1547
+ expected = Series (expected2 , dtype = object )
1530
1548
tm .assert_series_equal (result , expected )
1531
1549
1532
1550
@pytest .mark .parametrize (
@@ -1651,12 +1669,11 @@ def test_mode_intoverflow(self, dropna, expected1, expected2):
1651
1669
expected2 = Series (expected2 , dtype = np .uint64 )
1652
1670
tm .assert_series_equal (result , expected2 )
1653
1671
1654
- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
1655
1672
def test_mode_sortwarning (self ):
1656
1673
# Check for the warning that is raised when the mode
1657
1674
# results cannot be sorted
1658
1675
1659
- expected = Series (["foo" , np .nan ])
1676
+ expected = Series (["foo" , np .nan ], dtype = object )
1660
1677
s = Series ([1 , "foo" , "foo" , np .nan , np .nan ])
1661
1678
1662
1679
with tm .assert_produces_warning (UserWarning ):
0 commit comments