Skip to content

TST: Added iloc tests for casting from object to numeric dtypes for duplicate columns #41154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 30, 2021
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
15 changes: 15 additions & 0 deletions pandas/tests/indexing/test_iloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,21 @@ def test_iloc_setitem_series_duplicate_columns(self):
df.iloc[:, 0] = df.iloc[:, 0].astype(np.float64)
assert df.dtypes.iloc[2] == np.int64

@pytest.mark.parametrize(
["dtypes", "init_value", "expected_value"],
[("int64", "0", 0), ("float", "1.2", 1.2)],
)
def test_iloc_setitem_dtypes_duplicate_columns(
self, dtypes, init_value, expected_value
):
# GH#22035
df = DataFrame([[init_value, "str", "str2"]], columns=["a", "b", "b"])
df.iloc[:, 0] = df.iloc[:, 0].astype(dtypes)
expected_df = DataFrame(
[[expected_value, "str", "str2"]], columns=["a", "b", "b"]
)
tm.assert_frame_equal(df, expected_df)


class TestILocCallable:
def test_frame_iloc_getitem_callable(self):
Expand Down