Skip to content
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v2.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,8 @@ Deprecations
~~~~~~~~~~~~
- Deprecated argument ``infer_datetime_format`` in :func:`to_datetime` and :func:`read_csv`, as a strict version of it is now the default (:issue:`48621`)

- :meth:`Index.is_floating` has been deprecated. Use :func:`pandas.api.types.is_float_dtype` instead (:issue:`50042`)

.. ---------------------------------------------------------------------------

.. _whatsnew_200.prior_deprecations:
Expand Down
21 changes: 15 additions & 6 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2199,7 +2199,7 @@ def is_boolean(self) -> bool:
See Also
--------
is_integer : Check if the Index only consists of integers.
is_floating : Check if the Index is a floating type.
is_floating : Check if the Index is a floating type (deprecated).
is_numeric : Check if the Index only consists of numeric data.
is_object : Check if the Index is of the object dtype.
is_categorical : Check if the Index holds categorical data.
Expand Down Expand Up @@ -2234,7 +2234,7 @@ def is_integer(self) -> bool:
See Also
--------
is_boolean : Check if the Index only consists of booleans.
is_floating : Check if the Index is a floating type.
is_floating : Check if the Index is a floating type (deprecated).
is_numeric : Check if the Index only consists of numeric data.
is_object : Check if the Index is of the object dtype.
is_categorical : Check if the Index holds categorical data.
Expand All @@ -2261,6 +2261,9 @@ def is_floating(self) -> bool:
"""
Check if the Index is a floating type.

.. deprecated:: 2.0.0
Use `pandas.api.types.is_float_dtype` instead

The Index may consist of only floats, NaNs, or a mix of floats,
integers, or NaNs.

Expand Down Expand Up @@ -2297,6 +2300,12 @@ def is_floating(self) -> bool:
>>> idx.is_floating()
False
"""
warnings.warn(
f"{type(self).__name__}.is_floating is deprecated."
"Use pandas.api.types.is_float_dtype instead",
Comment on lines +2304 to +2305
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably could do with a space here.

FutureWarning,
stacklevel=find_stack_level(),
)
return self.inferred_type in ["floating", "mixed-integer-float", "integer-na"]

@final
Expand All @@ -2313,7 +2322,7 @@ def is_numeric(self) -> bool:
--------
is_boolean : Check if the Index only consists of booleans.
is_integer : Check if the Index only consists of integers.
is_floating : Check if the Index is a floating type.
is_floating : Check if the Index is a floating type (deprecated).
is_object : Check if the Index is of the object dtype.
is_categorical : Check if the Index holds categorical data.
is_interval : Check if the Index holds Interval objects.
Expand Down Expand Up @@ -2356,7 +2365,7 @@ def is_object(self) -> bool:
--------
is_boolean : Check if the Index only consists of booleans.
is_integer : Check if the Index only consists of integers.
is_floating : Check if the Index is a floating type.
is_floating : Check if the Index is a floating type (deprecated).
is_numeric : Check if the Index only consists of numeric data.
is_categorical : Check if the Index holds categorical data.
is_interval : Check if the Index holds Interval objects.
Expand Down Expand Up @@ -2397,7 +2406,7 @@ def is_categorical(self) -> bool:
CategoricalIndex : Index for categorical data.
is_boolean : Check if the Index only consists of booleans.
is_integer : Check if the Index only consists of integers.
is_floating : Check if the Index is a floating type.
is_floating : Check if the Index is a floating type (deprecated).
is_numeric : Check if the Index only consists of numeric data.
is_object : Check if the Index is of the object dtype.
is_interval : Check if the Index holds Interval objects.
Expand Down Expand Up @@ -2440,7 +2449,7 @@ def is_interval(self) -> bool:
IntervalIndex : Index for Interval objects.
is_boolean : Check if the Index only consists of booleans.
is_integer : Check if the Index only consists of integers.
is_floating : Check if the Index is a floating type.
is_floating : Check if the Index is a floating type (deprecated).
is_numeric : Check if the Index only consists of numeric data.
is_object : Check if the Index is of the object dtype.
is_categorical : Check if the Index holds categorical data.
Expand Down
6 changes: 6 additions & 0 deletions pandas/tests/indexes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,12 @@ def test_inv(self, simple_index):
with pytest.raises(TypeError, match=msg):
~Series(idx)

def test_is_floating_is_deprecated(self, simple_index):
# GH50042
idx = simple_index
with tm.assert_produces_warning(FutureWarning):
idx.is_floating()


class NumericBase(Base):
"""
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def test_index_type_coercion(self, indexer):

s2 = s.copy()
indexer(s2)[0.1] = 0
assert s2.index.is_floating()
assert is_float_dtype(s2.index)
assert indexer(s2)[0.1] == 0

s2 = s.copy()
Expand All @@ -621,11 +621,11 @@ def test_index_type_coercion(self, indexer):

for s in [Series(range(5), index=np.arange(5.0))]:

assert s.index.is_floating()
assert is_float_dtype(s.index)

s2 = s.copy()
indexer(s2)[0.1] = 0
assert s2.index.is_floating()
assert is_float_dtype(s2.index)
assert indexer(s2)[0.1] == 0

s2 = s.copy()
Expand Down