-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: DataFrame.__setitem__ raising ValueError with string indexer and empty df and df to set #38931
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 all commits
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 |
---|---|---|
|
@@ -338,6 +338,16 @@ def test_setitem_bool_with_numeric_index(self, dtype): | |
|
||
tm.assert_index_equal(df.columns, expected_cols) | ||
|
||
@pytest.mark.parametrize("indexer", ["B", ["B"]]) | ||
def test_setitem_frame_length_0_str_key(self, indexer): | ||
# GH#38831 | ||
df = DataFrame(columns=["A", "B"]) | ||
other = DataFrame({"B": [1, 2]}) | ||
df[indexer] = other | ||
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. do we need/want to check any of the other indexers? 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. Don't know if this would be helpful, the string-DataFrame case is a special case while indexer in [list, Index, Series, array] is all the same (which was working previously) 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. hmm, can you check 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. No unfortunately not, in case of When |
||
expected = DataFrame({"A": [np.nan] * 2, "B": [1, 2]}) | ||
expected["A"] = expected["A"].astype("object") | ||
tm.assert_frame_equal(df, expected) | ||
|
||
|
||
class TestDataFrameSetItemWithExpansion: | ||
def test_setitem_listlike_views(self): | ||
|
Uh oh!
There was an error while loading. Please reload this page.