Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions pandas/tests/indexing/test_iloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
Interval,
NaT,
Series,
Timestamp,
array,
concat,
date_range,
interval_range,
isna,
to_datetime,
)
import pandas._testing as tm
from pandas.api.types import is_scalar
Expand Down Expand Up @@ -1196,6 +1198,23 @@ def test_iloc_getitem_int_single_ea_block_view(self):
arr[2] = arr[-1]
assert ser[0] == arr[-1]

def test_iloc_setitem_multicolumn_to_datetime(self, using_array_manager):

# GH#20511
df = DataFrame({"A": ["2022-01-01", "2022-01-02"], "B": ["2021", "2022"]})

df.iloc[:, [0]] = DataFrame({"A": to_datetime(["2021", "2022"])})
expected = DataFrame(
{
"A": [
Timestamp("2021-01-01 00:00:00"),
Timestamp("2022-01-01 00:00:00"),
],
"B": ["2021", "2022"],
}
)
tm.assert_frame_equal(df, expected, check_dtype=using_array_manager)


class TestILocErrors:
# NB: this test should work for _any_ Series we can pass as
Expand Down