Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ Removal of prior version deprecations/changes
- Disallow automatic casting to object in :class:`Series` logical operations (``&``, ``^``, ``||``) between series with mismatched indexes and dtypes other than ``object`` or ``bool`` (:issue:`52538`)
- Disallow calling :meth:`Series.replace` or :meth:`DataFrame.replace` without a ``value`` and with non-dict-like ``to_replace`` (:issue:`33302`)
- Disallow constructing a :class:`arrays.SparseArray` with scalar data (:issue:`53039`)
- Disallow indexing an :class:`Index` with a boolean indexer of length zero, it now raises ``ValueError`` (:issue:`55820`)
- Disallow non-standard (``np.ndarray``, :class:`Index`, :class:`ExtensionArray`, or :class:`Series`) to :func:`isin`, :func:`unique`, :func:`factorize` (:issue:`52986`)
- Disallow passing a pandas type to :meth:`Index.view` (:issue:`55709`)
- Disallow units other than "s", "ms", "us", "ns" for datetime64 and timedelta64 dtypes in :func:`array` (:issue:`53817`)
Expand Down
9 changes: 3 additions & 6 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5033,12 +5033,9 @@ def __getitem__(self, key):

if not isinstance(self.dtype, ExtensionDtype):
if len(key) == 0 and len(key) != len(self):
warnings.warn(
"Using a boolean indexer with length 0 on an Index with "
"length greater than 0 is deprecated and will raise in a "
"future version.",
FutureWarning,
stacklevel=find_stack_level(),
raise ValueError(
"The length of the boolean indexer cannot be 0 "
"when the Index has length greater than 0."
)

result = getitem(key)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ def test_empty_fancy(self, index, dtype, request, using_infer_string):

assert index[[]].identical(empty_index)
if dtype == np.bool_:
with tm.assert_produces_warning(FutureWarning, match="is deprecated"):
with pytest.raises(ValueError, match="length of the boolean indexer"):
assert index[empty_arr].identical(empty_index)
else:
assert index[empty_arr].identical(empty_index)
Expand Down