Skip to content

BUG: Setting frame into df with dup cols loses dtypes #53143

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 3 commits into from
May 9, 2023

Conversation

phofl
Copy link
Member

@phofl phofl commented May 8, 2023

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

@phofl phofl added Indexing Related to indexing on series/frames, not to indexes themselves Bug labels May 8, 2023

def test_setitem_frame_dup_cols_dtype(self):
# GH#53143
df = DataFrame([[1, 2, 3, 4], [4, 5, 6, 7]], columns=["a", "b", "a", "c"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen if df has unique columns and rhs had duplicate columns?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we only get there with a scalar key, e.g. if columns are unique you'll end up with a single column. This would raise since your rhs dimension is too large

@mroeschke mroeschke added this to the 2.1 milestone May 9, 2023
@mroeschke mroeschke merged commit 9bd8b5d into pandas-dev:main May 9, 2023
@mroeschke
Copy link
Member

Thanks @phofl

@phofl phofl deleted the cow_setitem_frame branch May 10, 2023 05:40
Rylie-W pushed a commit to Rylie-W/pandas that referenced this pull request May 19, 2023
* BUG: Setting frame into df with dup cols loses dtypes

* BUG: Setting frame into df with dup cols loses dtypes

* Fix mypy
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
* BUG: Setting frame into df with dup cols loses dtypes

* BUG: Setting frame into df with dup cols loses dtypes

* Fix mypy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants