Skip to content

Commit 8513db2

Browse files
jbrockmendelproost
authored andcommitted
DEPR: ufunc.outer (pandas-dev#30104)
1 parent 2877667 commit 8513db2

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

doc/source/whatsnew/v1.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
604604
- Removed the previously deprecated :meth:`Series.to_dense`, :meth:`DataFrame.to_dense` (:issue:`26684`)
605605
- Removed the previously deprecated :meth:`Index.dtype_str`, use ``str(index.dtype)`` instead (:issue:`27106`)
606606
- :meth:`Categorical.ravel` returns a :class:`Categorical` instead of a ``ndarray`` (:issue:`27199`)
607+
- The 'outer' method on Numpy ufuncs, e.g. ``np.subtract.outer`` operating on :class:`Series` objects is no longer supported, and will raise ``NotImplementedError`` (:issue:`27198`)
607608
- Removed previously deprecated :meth:`Series.get_dtype_counts` and :meth:`DataFrame.get_dtype_counts` (:issue:`27145`)
608609
- Changed the default ``fill_value`` in :meth:`Categorical.take` from ``True`` to ``False`` (:issue:`20841`)
609610
- Changed the default value for the `raw` argument in :func:`Series.rolling().apply() <pandas.core.window.Rolling.apply>`, :func:`DataFrame.rolling().apply() <pandas.core.window.Rolling.apply>`,

pandas/core/series.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -684,14 +684,8 @@ def construct_return(result):
684684
elif result.ndim > 1:
685685
# e.g. np.subtract.outer
686686
if method == "outer":
687-
msg = (
688-
"outer method for ufunc {} is not implemented on "
689-
"pandas objects. Returning an ndarray, but in the "
690-
"future this will raise a 'NotImplementedError'. "
691-
"Consider explicitly converting the Series "
692-
"to an array with '.array' first."
693-
)
694-
warnings.warn(msg.format(ufunc), FutureWarning, stacklevel=3)
687+
# GH#27198
688+
raise NotImplementedError
695689
return result
696690
return self._constructor(result, index=index, name=name, copy=False)
697691

pandas/tests/series/test_ufunc.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,5 @@ def test_outer():
299299
s = pd.Series([1, 2, 3])
300300
o = np.array([1, 2, 3])
301301

302-
with tm.assert_produces_warning(FutureWarning):
303-
result = np.subtract.outer(s, o)
304-
expected = np.array([[0, -1, -2], [1, 0, -1], [2, 1, 0]], dtype=np.dtype("int64"))
305-
tm.assert_numpy_array_equal(result, expected)
302+
with pytest.raises(NotImplementedError):
303+
np.subtract.outer(s, o)

0 commit comments

Comments
 (0)