File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 21
21
Interval ,
22
22
NaT ,
23
23
Series ,
24
+ Timestamp ,
24
25
array ,
25
26
concat ,
26
27
date_range ,
27
28
interval_range ,
28
29
isna ,
30
+ to_datetime ,
29
31
)
30
32
import pandas ._testing as tm
31
33
from pandas .api .types import is_scalar
@@ -1196,6 +1198,23 @@ def test_iloc_getitem_int_single_ea_block_view(self):
1196
1198
arr [2 ] = arr [- 1 ]
1197
1199
assert ser [0 ] == arr [- 1 ]
1198
1200
1201
+ def test_iloc_setitem_multicolumn_to_datetime (self , using_array_manager ):
1202
+
1203
+ # GH#20511
1204
+ df = DataFrame ({"A" : ["2022-01-01" , "2022-01-02" ], "B" : ["2021" , "2022" ]})
1205
+
1206
+ df .iloc [:, [0 ]] = DataFrame ({"A" : to_datetime (["2021" , "2022" ])})
1207
+ expected = DataFrame (
1208
+ {
1209
+ "A" : [
1210
+ Timestamp ("2021-01-01 00:00:00" ),
1211
+ Timestamp ("2022-01-01 00:00:00" ),
1212
+ ],
1213
+ "B" : ["2021" , "2022" ],
1214
+ }
1215
+ )
1216
+ tm .assert_frame_equal (df , expected , check_dtype = using_array_manager )
1217
+
1199
1218
1200
1219
class TestILocErrors :
1201
1220
# NB: this test should work for _any_ Series we can pass as
You can’t perform that action at this time.
0 commit comments