Skip to content

Commit

Permalink
TST: Retyping of categorical column with NaN (#60112)
Browse files Browse the repository at this point in the history
* consistent name usage

* changed to numpy array of integers

* Remove redundant assert

Co-authored-by: Matthew Roeschke <[email protected]>

---------

Co-authored-by: Matthew Roeschke <[email protected]>
  • Loading branch information
SpoopyPillow and mroeschke authored Oct 30, 2024
1 parent 9cd4a28 commit 2a1ca9d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pandas/tests/dtypes/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,3 +1243,12 @@ def test_loc_setitem_empty_labels_no_dtype_conversion():

assert df.a.dtype == "int64"
tm.assert_frame_equal(df, expected)


def test_categorical_nan_no_dtype_conversion():
# GH 43996

df = pd.DataFrame({"a": Categorical([np.nan], [1]), "b": [1]})
expected = pd.DataFrame({"a": Categorical([1], [1]), "b": [1]})
df.loc[0, "a"] = np.array([1])
tm.assert_frame_equal(df, expected)

0 comments on commit 2a1ca9d

Please sign in to comment.