File tree 2 files changed +9
-7
lines changed
2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -998,10 +998,3 @@ def test_period_dtype_compare_to_string():
998
998
dtype = PeriodDtype (freq = "M" )
999
999
assert (dtype == "period[M]" ) is True
1000
1000
assert (dtype != "period[M]" ) is False
1001
-
1002
-
1003
- def test_column_not_loses_categorical_when_using_loc ():
1004
- # GH16360
1005
- df = pd .DataFrame ({"A" : [1 ]})
1006
- df .loc [:, "B" ] = Categorical (["a" ])
1007
- assert is_categorical_dtype (df ["B" ])
Original file line number Diff line number Diff line change @@ -386,3 +386,12 @@ def test_loc_indexing_preserves_index_category_dtype(self):
386
386
387
387
result = df .loc [["a" ]].index .levels [0 ]
388
388
tm .assert_index_equal (result , expected )
389
+
390
+
391
+ def test_column_not_loses_categorical_when_using_loc ():
392
+ # GH16360
393
+ result = DataFrame ({"A" : [1 ]})
394
+ result .loc [:, "B" ] = Categorical (["b" ])
395
+ expected = DataFrame ({"A" : [1 ], "B" : ["b" ]})
396
+ expected ["B" ] = expected ["B" ].astype ("category" )
397
+ tm .assert_frame_equal (result , expected )
You can’t perform that action at this time.
0 commit comments