Skip to content

Commit 20ff599

Browse files
jbrockmendeljorisvandenbossche
authored andcommitted
DEPR: infer_dtype default for skipna is now True (#29876)
1 parent 930b52a commit 20ff599

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

doc/source/whatsnew/v1.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
402402
**Other removals**
403403

404404
- Floordiv of integer-dtyped array by :class:`Timedelta` now raises ``TypeError`` (:issue:`21036`)
405+
- :func:`pandas.api.types.infer_dtype` argument ``skipna`` defaults to ``True`` instead of ``False`` (:issue:`24050`)
405406
- Removed the previously deprecated :meth:`Index.summary` (:issue:`18217`)
406407
- Removed the previously deprecated "fastpath" keyword from the :class:`Index` constructor (:issue:`23110`)
407408
- Removed the previously deprecated :meth:`Series.get_value`, :meth:`Series.set_value`, :meth:`DataFrame.get_value`, :meth:`DataFrame.set_value` (:issue:`17739`)

pandas/_libs/lib.pyx

+3-11
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ from fractions import Fraction
44
from numbers import Number
55

66
import sys
7-
import warnings
87

98
import cython
109
from cython import Py_ssize_t
@@ -615,7 +614,7 @@ def clean_index_list(obj: list):
615614

616615
# don't force numpy coerce with nan's
617616
inferred = infer_dtype(obj, skipna=False)
618-
if inferred in ['string', 'bytes', 'unicode', 'mixed', 'mixed-integer']:
617+
if inferred in ['string', 'bytes', 'mixed', 'mixed-integer']:
619618
return np.asarray(obj, dtype=object), 0
620619
elif inferred in ['integer']:
621620
# TODO: we infer an integer but it *could* be a uint64
@@ -1094,15 +1093,15 @@ cdef _try_infer_map(v):
10941093
return None
10951094

10961095

1097-
def infer_dtype(value: object, skipna: object=None) -> str:
1096+
def infer_dtype(value: object, skipna: bool = True) -> str:
10981097
"""
10991098
Efficiently infer the type of a passed val, or list-like
11001099
array of values. Return a string describing the type.
11011100

11021101
Parameters
11031102
----------
11041103
value : scalar, list, ndarray, or pandas type
1105-
skipna : bool, default False
1104+
skipna : bool, default True
11061105
Ignore NaN values when inferring the type.
11071106

11081107
.. versionadded:: 0.21.0
@@ -1113,7 +1112,6 @@ def infer_dtype(value: object, skipna: object=None) -> str:
11131112
Results can include:
11141113

11151114
- string
1116-
- unicode
11171115
- bytes
11181116
- floating
11191117
- integer
@@ -1200,12 +1198,6 @@ def infer_dtype(value: object, skipna: object=None) -> str:
12001198
bint seen_pdnat = False
12011199
bint seen_val = False
12021200

1203-
if skipna is None:
1204-
msg = ('A future version of pandas will default to `skipna=True`. To '
1205-
'silence this warning, pass `skipna=True|False` explicitly.')
1206-
warnings.warn(msg, FutureWarning, stacklevel=2)
1207-
skipna = False
1208-
12091201
if util.is_array(value):
12101202
values = value
12111203
elif hasattr(value, 'dtype'):

pandas/tests/dtypes/test_inference.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -628,13 +628,13 @@ def test_integer_na(self, arr, skipna):
628628
expected = "integer" if skipna else "integer-na"
629629
assert result == expected
630630

631-
def test_deprecation(self):
632-
# GH 24050
633-
arr = np.array([1, 2, 3], dtype=object)
631+
def test_infer_dtype_skipna_default(self):
632+
# infer_dtype `skipna` default deprecated in GH#24050,
633+
# changed to True in GH#29876
634+
arr = np.array([1, 2, 3, np.nan], dtype=object)
634635

635-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
636-
result = lib.infer_dtype(arr) # default: skipna=None -> warn
637-
assert result == "integer"
636+
result = lib.infer_dtype(arr)
637+
assert result == "integer"
638638

639639
def test_bools(self):
640640
arr = np.array([True, False, True, True, True], dtype="O")

0 commit comments

Comments
 (0)