Skip to content

Commit 786213a

Browse files
committed
DOC: whatsnew for array_ufunc
xref pandas-dev#27186 (comment)
1 parent c407b73 commit 786213a

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

doc/source/whatsnew/v0.25.0.rst

+42
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,48 @@ previous behavior of returning overlapping matches.
620620
s[idxr]
621621
s.loc[idxr]
622622
623+
624+
.. _whatsnew_0250.api_breaking.ufunc:
625+
626+
Binary ufuncs on Series now aligns
627+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
628+
629+
Applying a binary ufunc like :func:`numpy.power` now aligns the inputs
630+
when both are :class:`Series` (:issue:`23293`).
631+
632+
.. ipython:: python:
633+
634+
s1 = pd.Series([1, 2, 3], index=['a', 'b', 'c'])
635+
s2 = pd.Series([3, 4, 5], index=['d', 'c', 'b'])
636+
s1
637+
s2
638+
639+
*Previous behavior*
640+
641+
.. code-block:: python
642+
643+
In [5]: np.power(s1, s2)
644+
Out[5]:
645+
a 1
646+
b 16
647+
c 243
648+
dtype: int64
649+
650+
*New behavior*
651+
652+
.. ipython:: python
653+
654+
np.power(s1, s2)
655+
656+
This matches the behavior of other binary operations in pandas, like :meth:`Series.add`.
657+
To retain the previous behavior, convert the other ``Series`` to an array before
658+
applying the ufunc
659+
660+
.. ipython:: python
661+
662+
np.power(s1, s2.array)
663+
664+
623665
.. _whatsnew_0250.api_breaking.deps:
624666
625667
Increased minimum versions for dependencies

0 commit comments

Comments
 (0)