Skip to content

Commit 45fb051

Browse files
author
Tristan Marechaux
committed
DEPR: Series.ravel
1 parent 23f74d3 commit 45fb051

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

doc/source/whatsnew/v2.1.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ Deprecations
232232
- Deprecated :func:`is_interval_dtype`, check ``isinstance(dtype, pd.IntervalDtype)`` instead (:issue:`52607`)
233233
- Deprecated :meth:`DataFrame.applymap`. Use the new :meth:`DataFrame.map` method instead (:issue:`52353`)
234234
- Deprecated :meth:`DataFrame.swapaxes` and :meth:`Series.swapaxes`, use :meth:`DataFrame.transpose` or :meth:`Series.transpose` instead (:issue:`51946`)
235+
- Deprecated :meth:`Series.ravel` (:issue:`52511`)
235236
- Deprecated ``freq`` parameter in :class:`PeriodArray` constructor, pass ``dtype`` instead (:issue:`52462`)
236237
- Deprecated behavior of :meth:`Series.dt.to_pydatetime`, in a future version this will return a :class:`Series` containing python ``datetime`` objects instead of an ``ndarray`` of datetimes; this matches the behavior of other :meth:`Series.dt` properties (:issue:`20306`)
237238
- Deprecated logical operations (``|``, ``&``, ``^``) between pandas objects and dtype-less sequences (e.g. ``list``, ``tuple``), wrap a sequence in a :class:`Series` or numpy array before operating instead (:issue:`51521`)
@@ -243,7 +244,6 @@ Deprecations
243244
- Deprecated the methods :meth:`Series.bool` and :meth:`DataFrame.bool` (:issue:`51749`)
244245
- Deprecated unused "closed" and "normalize" keywords in the :class:`DatetimeIndex` constructor (:issue:`52628`)
245246
- Deprecated unused "closed" keyword in the :class:`TimedeltaIndex` constructor (:issue:`52628`)
246-
-
247247

248248
.. ---------------------------------------------------------------------------
249249
.. _whatsnew_210.performance:

pandas/core/series.py

+7
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,13 @@ def ravel(self, order: str = "C") -> ArrayLike:
770770
--------
771771
numpy.ndarray.ravel : Return a flattened array.
772772
"""
773+
warnings.warn(
774+
# GH#52511
775+
f"'{type(self).__name__}.ravel' is deprecated and will be removed in a "
776+
f"future version.",
777+
FutureWarning,
778+
stacklevel=find_stack_level(),
779+
)
773780
arr = self._values.ravel(order=order)
774781
if isinstance(arr, np.ndarray) and using_copy_on_write():
775782
arr.flags.writeable = False

pandas/tests/series/test_api.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ def test_ndarray_compat_like_func(self):
142142
def test_ndarray_compat_ravel(self):
143143
# ravel
144144
s = Series(np.random.randn(10))
145-
tm.assert_almost_equal(s.ravel(order="F"), s.values.ravel(order="F"))
145+
msg = "'Series.ravel' is deprecated"
146+
with tm.assert_produces_warning(FutureWarning, match=msg):
147+
tm.assert_almost_equal(s.ravel(order="F"), s.values.ravel(order="F"))
146148

147149
def test_empty_method(self):
148150
s_empty = Series(dtype=object)

0 commit comments

Comments
 (0)