We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8d2ca0b commit 4964c39Copy full SHA for 4964c39
pandas/tests/dtypes/test_dtypes.py
@@ -1243,3 +1243,15 @@ def test_loc_setitem_empty_labels_no_dtype_conversion():
1243
1244
assert df.a.dtype == "int64"
1245
tm.assert_frame_equal(df, expected)
1246
+
1247
1248
+def test_categorical_nan_no_dtype_conversion():
1249
+ # GH 43996
1250
1251
+ df = pd.DataFrame({"a": Categorical([np.nan], [1]), "b": [1]})
1252
+ expected = pd.DataFrame({"a": Categorical([1], [1]), "b": [1]})
1253
+ assert df["a"].dtype == "category"
1254
1255
+ df.loc[0, "a"] = 1
1256
1257
+ tm.assert_frame_equal(df, expected)
0 commit comments