@@ -146,6 +146,25 @@ def test_astype_cast_via_loc_nan_int(self, val, dtype):
146
146
df .loc [:, "b" ] = df .loc [:, "b" ].astype (dtype )
147
147
tm .assert_frame_equal (df , expected )
148
148
149
+ expected2 = DataFrame (
150
+ {"a" : ["foo" , "foo" ], "b" : integer_array ([val , 1.0 ], dtype = dtype )}
151
+ )
152
+ df2 = DataFrame ({"a" : ["foo" , "foo" ], "b" : [val , 1.0 ]})
153
+ df2 .loc [:, "b" ] = df2 .loc [:, "b" ].astype (dtype )
154
+ tm .assert_frame_equal (df2 , expected2 )
155
+
156
+ expected3 = DataFrame (
157
+ {"a" : ["foo" , "foo" ], "b" : integer_array ([val , val ], dtype = dtype )}
158
+ )
159
+ df3 = DataFrame ({"a" : ["foo" , "foo" ], "b" : [val , val ]})
160
+ df3 .loc [:, "b" ] = df3 .loc [:, "b" ].astype (dtype )
161
+ tm .assert_frame_equal (df3 , expected3 )
162
+
163
+ expected4 = DataFrame ({"b" : integer_array ([val ], dtype = dtype )})
164
+ df4 = DataFrame ({"b" : [val ]})
165
+ df4 .loc [:, "b" ] = df4 .loc [:, "b" ].astype (dtype )
166
+ tm .assert_frame_equal (df4 , expected4 )
167
+
149
168
def test_astype_str (self ):
150
169
# see GH#9757
151
170
a = Series (date_range ("2010-01-04" , periods = 5 ))
0 commit comments