Skip to content

Commit

Permalink
DEPR: Index.is_mixed (#33291)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel authored Apr 5, 2020
1 parent b71e807 commit a9b051c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ Deprecations
- :meth:`DataFrame.to_dict` has deprecated accepting short names for ``orient`` in future versions (:issue:`32515`)
- :meth:`Categorical.to_dense` is deprecated and will be removed in a future version, use ``np.asarray(cat)`` instead (:issue:`32639`)
- The ``fastpath`` keyword in the ``SingleBlockManager`` constructor is deprecated and will be removed in a future version (:issue:`33092`)
- :meth:`Index.is_mixed` is deprecated and will be removed in a future version, check ``index.inferred_type`` directly instead (:issue:`32922`)

.. ---------------------------------------------------------------------------
Expand Down
8 changes: 7 additions & 1 deletion pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1955,6 +1955,12 @@ def is_mixed(self) -> bool:
>>> idx.is_mixed()
False
"""
warnings.warn(
"Index.is_mixed is deprecated and will be removed in a future version. "
"Check index.inferred_type directly instead.",
FutureWarning,
stacklevel=2,
)
return self.inferred_type in ["mixed"]

def holds_integer(self) -> bool:
Expand Down Expand Up @@ -3131,7 +3137,7 @@ def is_int(v):
# convert the slice to an indexer here

# if we are mixed and have integers
if is_positional and self.is_mixed():
if is_positional:
try:
# Validate start & stop
if start is not None:
Expand Down
6 changes: 6 additions & 0 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,12 @@ def test_intersection_difference(self, indices, sort):
diff = indices.difference(indices, sort=sort)
tm.assert_index_equal(inter, diff)

def test_is_mixed_deprecated(self):
# GH#32922
index = self.create_index()
with tm.assert_produces_warning(FutureWarning):
index.is_mixed()

@pytest.mark.parametrize(
"indices, expected",
[
Expand Down

0 comments on commit a9b051c

Please # to comment.