-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
BUG: Series.setitem raising ValueError when setting Series with scalar indexer #39358
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 1 commit
Commits
Show all changes
8 commits Select commit Hold shift + click to select a range
09cc7f4 BUG: Series.setitem raising ValueError when setting Series with scala…
phofl 2cb7a7b Handle non object dtype series
phofl 78450b9 Remove brackets
phofl 33845f4 Improve performance
phofl 9e7a46a Use is integer
phofl 29ba005 Merge branch 'master' of https://github.com/pandas-dev/pandas into 38303
phofl 38a66e9 Parametrize
phofl 371f88f Replace is_scalar
phofl 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
Handle non object dtype series
- Loading branch information
commit 2cb7a7b9e97a88d9e0cb93408a3887dca82b3a61
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -93,11 +93,20 @@ def test_setitem_negative_out_of_bounds(self): | |
| with pytest.raises(IndexError, match=msg): | ||
| ser[-11] = "foo" | ||
| | ||
| def test_setitem_series(self): | ||
| @pytest.mark.parametrize("ser_index", [0, 1]) | ||
| Contributor 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. can you parameterize over Member Author 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. Thanks, did not know that. Yes they do not align | ||
| def test_setitem_series_object_dtype(self, ser_index): | ||
| # GH#38303 | ||
| ser = Series(0, index=[0, 1, 2]) | ||
| ser[0] = Series([42]) | ||
| expected = Series([42, 0, 0]) | ||
| ser = Series([0, 0], dtype="object") | ||
| ser.loc[0] = Series([42], index=[ser_index]) | ||
| expected = Series([Series([42], index=[ser_index]), 0], dtype="object") | ||
| tm.assert_series_equal(ser, expected) | ||
| | ||
| @pytest.mark.parametrize("index, exp_value", [(0, 42.0), (1, np.nan)]) | ||
| def test_setitem_series(self, index, exp_value): | ||
| # GH#38303 | ||
| ser = Series([0, 0]) | ||
| ser.loc[0] = Series([42], index=[index]) | ||
| expected = Series([exp_value, 0]) | ||
| tm.assert_series_equal(ser, expected) | ||
| | ||
| | ||
| | ||
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.