-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: loc setitem with missing integer slices does not raise #30921
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
BUG: loc setitem with missing integer slices does not raise #30921
Conversation
There are two reasons for updating an old test case
Hope that sounds convincing. |
This change has a huge impact on existing test cases. Let me investigate further. |
@@ -1036,6 +1036,7 @@ Indexing | |||
- :meth:`MultiIndex.get_loc` can't find missing values when input includes missing values (:issue:`19132`) | |||
- Bug in :meth:`Series.__setitem__` incorrectly assigning values with boolean indexer when the length of new data matches the number of ``True`` values and new data is not a ``Series`` or an ``np.array`` (:issue:`30567`) | |||
- Bug in indexing with a :class:`PeriodIndex` incorrectly accepting integers representing years, use e.g. ``ser.loc["2007"]`` instead of ``ser.loc[2007]`` (:issue:`30763`) | |||
- Bug in :meth:`DataFrame.loc.__setitem__` and :meth:`Series.loc.__setitem__` not raising error when given integer slice does not exist in index (:issue:`26412`) |
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.
- Bug in :meth:`DataFrame.loc.__setitem__` and :meth:`Series.loc.__setitem__` not raising error when given integer slice does not exist in index (:issue:`26412`) | |
- Bug in :meth:`DataFrame.loc.__setitem__` and :meth:`Series.loc.__setitem__` not raising error when given integer slice that do not exist in the index (:issue:`26412`) |
# GH 26412 | ||
df = DataFrame({"col1": [1, 2, 3]}, index=["a", "b", "c"]) | ||
msg = "cannot do slice indexing on .* with these indexers" | ||
with pytest.raises(TypeError, match=msg): |
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.
Newline above this one
@@ -2922,6 +2922,9 @@ def is_int(v): | |||
self._validate_indexer("slice", key.step, kind), | |||
) | |||
|
|||
if kind == "loc" and not is_null_slicer: | |||
return self.slice_indexer(key.start, key.stop, key.step, kind=kind) | |||
|
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.
is any of the validation on L2931-2948 relevant? can some or all of it be removed?
This likely affects some tests, see how this is handled in #31840.
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.
hey sorry I haven't had time to work on this.
will close this PR in favor of #31840.
closing this PR in favor of #31840. |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff