@@ -505,6 +505,32 @@ def test_int_factorize_use_na_sentinel_false(
505
505
tm .assert_numpy_array_equal (uniques , expected_uniques , strict_nan = True )
506
506
tm .assert_numpy_array_equal (codes , expected_codes , strict_nan = True )
507
507
508
+ @pytest .mark .parametrize (
509
+ "data, expected_codes, expected_uniques" ,
510
+ [
511
+ (
512
+ Index (Categorical (["a" , "a" , "b" ])),
513
+ np .array ([0 , 0 , 1 ], dtype = np .intp ),
514
+ CategoricalIndex (["a" , "b" ], categories = ["a" , "b" ], dtype = "category" ),
515
+ ),
516
+ (
517
+ Series (Categorical (["a" , "a" , "b" ])),
518
+ np .array ([0 , 0 , 1 ], dtype = np .intp ),
519
+ CategoricalIndex (["a" , "b" ], categories = ["a" , "b" ], dtype = "category" ),
520
+ ),
521
+ (
522
+ Series (DatetimeIndex (["2017" , "2017" ], tz = "US/Eastern" )),
523
+ np .array ([0 , 0 ], dtype = np .intp ),
524
+ DatetimeIndex (["2017" ], tz = "US/Eastern" ),
525
+ ),
526
+ ],
527
+ )
528
+ def test_factorize_mixed_values (self , data , expected_codes , expected_uniques ):
529
+ # GH 19721
530
+ codes , uniques = algos .factorize (data )
531
+ tm .assert_numpy_array_equal (codes , expected_codes )
532
+ tm .assert_index_equal (uniques , expected_uniques )
533
+
508
534
509
535
class TestUnique :
510
536
def test_ints (self ):
0 commit comments