File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -143,6 +143,37 @@ def test_setitem_from_duplicate_axis(self):
143
143
)
144
144
tm .assert_frame_equal (df , expected )
145
145
146
+ def test_column_types_consistent (self ):
147
+ # GH 26779
148
+ df = DataFrame (
149
+ data = {
150
+ "channel" : [1 , 2 , 3 ],
151
+ "A" : ["String 1" , np .NaN , "String 2" ],
152
+ "B" : [
153
+ Timestamp ("2019-06-11 11:00:00" ),
154
+ pd .NaT ,
155
+ Timestamp ("2019-06-11 12:00:00" ),
156
+ ],
157
+ }
158
+ )
159
+ df2 = DataFrame (
160
+ data = {"A" : ["String 3" ], "B" : [Timestamp ("2019-06-11 12:00:00" )]}
161
+ )
162
+ # Change Columns A and B to df2.values wherever Column A is NaN
163
+ df .loc [df ["A" ].isna (), ["A" , "B" ]] = df2 .values
164
+ expected = DataFrame (
165
+ data = {
166
+ "channel" : [1 , 2 , 3 ],
167
+ "A" : ["String 1" , "String 3" , "String 2" ],
168
+ "B" : [
169
+ Timestamp ("2019-06-11 11:00:00" ),
170
+ Timestamp ("2019-06-11 12:00:00" ),
171
+ Timestamp ("2019-06-11 12:00:00" ),
172
+ ],
173
+ }
174
+ )
175
+ tm .assert_frame_equal (df , expected )
176
+
146
177
147
178
class TestLoc2 :
148
179
# TODO: better name, just separating out things that rely on base class
You can’t perform that action at this time.
0 commit comments