Skip to content

Commit ec4a003

Browse files
committed
Deprecate series.nonzero (GH18262)
1 parent b45eb26 commit ec4a003

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

doc/source/whatsnew/v0.24.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,7 @@ Deprecations
11231123
- :func:`pandas.types.is_period` is deprecated in favor of `pandas.types.is_period_dtype` (:issue:`23917`)
11241124
- :func:`pandas.types.is_datetimetz` is deprecated in favor of `pandas.types.is_datetime64tz` (:issue:`23917`)
11251125
- Creating a :class:`TimedeltaIndex` or :class:`DatetimeIndex` by passing range arguments `start`, `end`, and `periods` is deprecated in favor of :func:`timedelta_range` and :func:`date_range` (:issue:`23919`)
1126+
- :meth:`Series.nonzero` is deprecated and will be removed in a future version (:issue:`18262`)
11261127

11271128
.. _whatsnew_0240.deprecations.datetimelike_int_ops:
11281129

pandas/core/series.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,8 @@ def nonzero(self):
535535
"""
536536
Return the *integer* indices of the elements that are non-zero.
537537
538+
.. deprecated:: 0.24.0
539+
538540
This method is equivalent to calling `numpy.nonzero` on the
539541
series data. For compatibility with NumPy, the return value is
540542
the same (a tuple with an array of indices for each dimension),
@@ -564,6 +566,9 @@ def nonzero(self):
564566
--------
565567
numpy.nonzero
566568
"""
569+
msg = ("Series.nonzero() is deprecated "
570+
"and will be removed in a future version.")
571+
warnings.warn(msg, FutureWarning, stacklevel=2)
567572
return self._values.nonzero()
568573

569574
def put(self, *args, **kwargs):

0 commit comments

Comments
 (0)