-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: Ensure that setitem ops don't coerce values #51671
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,6 @@ def test_insert_frame(self): | |
# GH#42403 | ||
df = DataFrame({"col1": [1, 2], "col2": [3, 4]}) | ||
|
||
msg = r"Expected a 1D array, got an array with shape \(2, 2\)" | ||
msg = "Expected a one-dimensional object, got a DataFrame with 2 instead." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "2" here sounds like it is referring to 2 dimensions, which is accurate but i think not intended There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yikes yes, I forgot to add columns, thx There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated, otherwise ok? I think making this stricter helps in the long run |
||
with pytest.raises(ValueError, match=msg): | ||
df.insert(1, "newcol", df) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no other cases that can be affected by disallowing this here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None that I can think of or find. Isetitem iterates over the columns now. Don’t think that we can get here with a DataFrame now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for checking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for this PR, but some things I saw while double-checking:
in isetitem isinstance(value, DataFrame) case should we check that len(loc) == len(value.columns)?
_iset_item is only called from _replace_columnwise, where we know we have a Series with matching index, might be simpler to skip sanitize_column?
Might make sense to refactor _set_item back into
__setitem__
, as the latter isn't that complicated and the former has a name really similar to a bunch of other namesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.