File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 33import numpy as np
44import pytest
55
6- from pandas import DataFrame , Series , Timestamp
6+ from pandas import CategoricalDtype , DataFrame , Series , Timestamp
77import pandas ._testing as tm
88
99
@@ -26,6 +26,23 @@ def test_at_setitem_mixed_index_assignment(self):
2626 ser .at [1 ] = 22
2727 assert ser .iat [3 ] == 22
2828
29+ def test_at_setitem_categorical_missing (self ):
30+ df = DataFrame (
31+ index = range (3 ), columns = range (3 ), dtype = CategoricalDtype (["foo" , "bar" ])
32+ )
33+ df .at [1 , 1 ] = "foo"
34+
35+ expected = DataFrame (
36+ [
37+ [np .nan , np .nan , np .nan ],
38+ [np .nan , "foo" , np .nan ],
39+ [np .nan , np .nan , np .nan ],
40+ ],
41+ dtype = CategoricalDtype (["foo" , "bar" ]),
42+ )
43+
44+ tm .assert_frame_equal (df , expected )
45+
2946
3047class TestAtSetItemWithExpansion :
3148 def test_at_setitem_expansion_series_dt64tz_value (self , tz_naive_fixture ):
You can’t perform that action at this time.
0 commit comments