From 3a8085eb880d21c5ad849abd4bbbe5dcc9d846b8 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Tue, 2 Jul 2019 13:03:12 -0500 Subject: [PATCH 1/2] DOC: whatsnew for array_ufunc xref https://github.com/pandas-dev/pandas/issues/27186#issuecomment-507768331 --- doc/source/whatsnew/v0.25.0.rst | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index e9d23cfd8efc1..74f8d1e958751 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -620,6 +620,48 @@ previous behavior of returning overlapping matches. s[idxr] s.loc[idxr] + +.. _whatsnew_0250.api_breaking.ufunc: + +Binary ufuncs on Series now align +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Applying a binary ufunc like :func:`numpy.power` now aligns the inputs +when both are :class:`Series` (:issue:`23293`). + +.. ipython:: python: + + s1 = pd.Series([1, 2, 3], index=['a', 'b', 'c']) + s2 = pd.Series([3, 4, 5], index=['d', 'c', 'b']) + s1 + s2 + +*Previous behavior* + +.. code-block:: python + + In [5]: np.power(s1, s2) + Out[5]: + a 1 + b 16 + c 243 + dtype: int64 + +*New behavior* + +.. ipython:: python + + np.power(s1, s2) + +This matches the behavior of other binary operations in pandas, like :meth:`Series.add`. +To retain the previous behavior, convert the other ``Series`` to an array before +applying the ufunc. + +.. ipython:: python + + np.power(s1, s2.array) + + .. _whatsnew_0250.api_breaking.deps: Increased minimum versions for dependencies From a2239e3730c1c0f4d42f92df2e7877809ce989e3 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Tue, 2 Jul 2019 15:05:52 -0500 Subject: [PATCH 2/2] Update doc/source/whatsnew/v0.25.0.rst --- doc/source/whatsnew/v0.25.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index 74f8d1e958751..625469de9b947 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -629,7 +629,7 @@ Binary ufuncs on Series now align Applying a binary ufunc like :func:`numpy.power` now aligns the inputs when both are :class:`Series` (:issue:`23293`). -.. ipython:: python: +.. ipython:: python s1 = pd.Series([1, 2, 3], index=['a', 'b', 'c']) s2 = pd.Series([3, 4, 5], index=['d', 'c', 'b'])