Skip to content

Commit 9ac75ca

Browse files
TomAugspurgerjreback
authored andcommitted
DOC: whatsnew for array_ufunc (#27188)
1 parent 212df86 commit 9ac75ca

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
@@ -643,6 +643,48 @@ previous behavior of returning overlapping matches.
643643
s[idxr]
644644
s.loc[idxr]
645645
646+
647+
.. _whatsnew_0250.api_breaking.ufunc:
648+
649+
Binary ufuncs on Series now align
650+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
651+
652+
Applying a binary ufunc like :func:`numpy.power` now aligns the inputs
653+
when both are :class:`Series` (:issue:`23293`).
654+
655+
.. ipython:: python
656+
657+
s1 = pd.Series([1, 2, 3], index=['a', 'b', 'c'])
658+
s2 = pd.Series([3, 4, 5], index=['d', 'c', 'b'])
659+
s1
660+
s2
661+
662+
*Previous behavior*
663+
664+
.. code-block:: python
665+
666+
In [5]: np.power(s1, s2)
667+
Out[5]:
668+
a 1
669+
b 16
670+
c 243
671+
dtype: int64
672+
673+
*New behavior*
674+
675+
.. ipython:: python
676+
677+
np.power(s1, s2)
678+
679+
This matches the behavior of other binary operations in pandas, like :meth:`Series.add`.
680+
To retain the previous behavior, convert the other ``Series`` to an array before
681+
applying the ufunc.
682+
683+
.. ipython:: python
684+
685+
np.power(s1, s2.array)
686+
687+
646688
.. _whatsnew_0250.api_breaking.deps:
647689
648690
Increased minimum versions for dependencies

0 commit comments

Comments
 (0)