Skip to content

Commit 40a99dd

Browse files
committed
add test to verify column does not lose categorical type when using loc
1 parent fb379d8 commit 40a99dd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pandas/tests/dtypes/test_dtypes.py

+7
Original file line numberDiff line numberDiff line change
@@ -998,3 +998,10 @@ def test_period_dtype_compare_to_string():
998998
dtype = PeriodDtype(freq="M")
999999
assert (dtype == "period[M]") is True
10001000
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"])

0 commit comments

Comments
 (0)