File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 2121 Interval ,
2222 NaT ,
2323 Series ,
24+ Timestamp ,
2425 array ,
2526 concat ,
2627 date_range ,
2728 interval_range ,
2829 isna ,
30+ to_datetime ,
2931)
3032import pandas ._testing as tm
3133from pandas .api .types import is_scalar
@@ -1196,6 +1198,23 @@ def test_iloc_getitem_int_single_ea_block_view(self):
11961198 arr [2 ] = arr [- 1 ]
11971199 assert ser [0 ] == arr [- 1 ]
11981200
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+
11991218
12001219class TestILocErrors :
12011220 # NB: this test should work for _any_ Series we can pass as
You can’t perform that action at this time.
0 commit comments