-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
BUG: iloc.__setitem__ with dict value and mixed dtypes #38335
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
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8a142d3
BUG: iloc.__setitem__ with dict value and mixed dtypes
jbrockmendel 4197450
GH ref
jbrockmendel d383a88
Merge branch 'master' of http://github.com/pandas-dev/pandas into bu…
jbrockmendel e1f4aed
whatsnew
jbrockmendel 73518be
revert 1.2.0 whatnsew
jbrockmendel d656f92
Merge branch 'master' of http://github.com/pandas-dev/pandas into bu…
jbrockmendel 255aa26
remove unused frame
jbrockmendel be83f16
update whatsnew
jbrockmendel 748417b
Merge branch 'master' of http://github.com/pandas-dev/pandas into bu…
jbrockmendel 882699d
Merge branch 'master' of http://github.com/pandas-dev/pandas into bu…
jbrockmendel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -741,13 +741,21 @@ def test_slice_with_zero_step_raises(self): | |
s.loc[::0] | ||
|
||
def test_indexing_assignment_dict_already_exists(self): | ||
df = DataFrame({"x": [1, 2, 6], "y": [2, 2, 8], "z": [-5, 0, 5]}).set_index("z") | ||
index = Index([-5, 0, 5], name="z") | ||
df = DataFrame({"x": [1, 2, 6], "y": [2, 2, 8]}, index=index) | ||
expected = df.copy() | ||
rhs = {"x": 9, "y": 99} | ||
df.loc[5] = rhs | ||
expected.loc[5] = [9, 99] | ||
tm.assert_frame_equal(df, expected) | ||
|
||
# GH#38335 same thing, mixed dtypes | ||
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. was this broken too? (or just iloc as indicated)? is 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. loc is broken too. setitem is OK i think. |
||
df = DataFrame({"x": [1, 2, 6], "y": [2.0, 2.0, 8.0]}, index=index) | ||
expected = df.copy() | ||
df.loc[5] = rhs | ||
expected = DataFrame({"x": [1, 2, 9], "y": [2.0, 2.0, 99.0]}, index=index) | ||
tm.assert_frame_equal(df, expected) | ||
|
||
def test_indexing_dtypes_on_empty(self): | ||
# Check that .iloc returns correct dtypes GH9983 | ||
df = DataFrame({"a": [1, 2, 3], "b": ["b", "b2", "b3"]}) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.