@@ -453,22 +453,6 @@ def test_astype_extension_dtypes_duplicate_col(self, dtype):
453
453
expected = concat ([a1 .astype (dtype ), a2 .astype (dtype )], axis = 1 )
454
454
tm .assert_frame_equal (result , expected )
455
455
456
- @pytest .mark .parametrize ("kwargs" , [dict (), dict (other = None )])
457
- def test_df_where_with_category (self , kwargs ):
458
- # GH 16979
459
- df = DataFrame (np .arange (2 * 3 ).reshape (2 , 3 ), columns = list ("ABC" ))
460
- mask = np .array ([[True , False , True ], [False , True , True ]])
461
-
462
- # change type to category
463
- df .A = df .A .astype ("category" )
464
- df .B = df .B .astype ("category" )
465
- df .C = df .C .astype ("category" )
466
-
467
- result = df .A .where (mask [:, 0 ], ** kwargs )
468
- expected = Series (pd .Categorical ([0 , np .nan ], categories = [0 , 3 ]), name = "A" )
469
-
470
- tm .assert_series_equal (result , expected )
471
-
472
456
@pytest .mark .parametrize (
473
457
"dtype" , [{100 : "float64" , 200 : "uint64" }, "category" , "float64" ]
474
458
)
@@ -479,31 +463,6 @@ def test_astype_column_metadata(self, dtype):
479
463
df = df .astype (dtype )
480
464
tm .assert_index_equal (df .columns , columns )
481
465
482
- def test_df_where_change_dtype (self ):
483
- # GH 16979
484
- df = DataFrame (np .arange (2 * 3 ).reshape (2 , 3 ), columns = list ("ABC" ))
485
- mask = np .array ([[True , False , False ], [False , False , True ]])
486
-
487
- result = df .where (mask )
488
- expected = DataFrame (
489
- [[0 , np .nan , np .nan ], [np .nan , np .nan , 5 ]], columns = list ("ABC" )
490
- )
491
-
492
- tm .assert_frame_equal (result , expected )
493
-
494
- # change type to category
495
- df .A = df .A .astype ("category" )
496
- df .B = df .B .astype ("category" )
497
- df .C = df .C .astype ("category" )
498
-
499
- result = df .where (mask )
500
- A = pd .Categorical ([0 , np .nan ], categories = [0 , 3 ])
501
- B = pd .Categorical ([np .nan , np .nan ], categories = [1 , 4 ])
502
- C = pd .Categorical ([np .nan , 5 ], categories = [2 , 5 ])
503
- expected = DataFrame ({"A" : A , "B" : B , "C" : C })
504
-
505
- tm .assert_frame_equal (result , expected )
506
-
507
466
@pytest .mark .parametrize ("dtype" , ["M8" , "m8" ])
508
467
@pytest .mark .parametrize ("unit" , ["ns" , "us" , "ms" , "s" , "h" , "m" , "D" ])
509
468
def test_astype_from_datetimelike_to_object (self , dtype , unit ):
0 commit comments