File tree 1 file changed +18
-1
lines changed
1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 3
3
import numpy as np
4
4
import pytest
5
5
6
- from pandas import DataFrame , Series , Timestamp
6
+ from pandas import CategoricalDtype , DataFrame , Series , Timestamp
7
7
import pandas ._testing as tm
8
8
9
9
@@ -26,6 +26,23 @@ def test_at_setitem_mixed_index_assignment(self):
26
26
ser .at [1 ] = 22
27
27
assert ser .iat [3 ] == 22
28
28
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
+
29
46
30
47
class TestAtSetItemWithExpansion :
31
48
def test_at_setitem_expansion_series_dt64tz_value (self , tz_naive_fixture ):
You can’t perform that action at this time.
0 commit comments