Skip to content

Commit 5d22662

Browse files
committed
fix errors
1 parent 0d60638 commit 5d22662

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

doc/source/user_guide/basics.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ resulting column names will be the transforming functions.
11191119

11201120
.. ipython:: python
11211121
1122-
tsdf["A"].transform([np.abs, lambda x: x + 1])
1122+
tsdf["A"].transform([np.abs, lambda x: x + 1], series_ops_only=True)
11231123
11241124
11251125
Transforming with a dict

pandas/tests/apply/common.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import numpy as np
2+
13
import pandas as pd
24
import pandas._testing as tm
35
from pandas.api.types import is_list_like
@@ -12,7 +14,9 @@
1214

1315
def transform_obj(obj, func, *args, axis=0, series_ops_only=False, **kwargs):
1416
"""helper function to ease use of series_ops_only and deprecation warning."""
15-
if series_ops_only:
17+
if isinstance(func, np.ufunc):
18+
result = obj.transform(func, axis, *args, **kwargs)
19+
elif series_ops_only:
1620
result = obj.transform(
1721
func, axis, *args, series_ops_only=series_ops_only, **kwargs
1822
)

pandas/tests/apply/test_frame_transform.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ def unpack_obj(obj, klass, axis):
2828
return obj
2929

3030

31-
def test_transform_ufunc(axis, float_frame, frame_or_series, series_ops_only):
31+
def test_transform_ufunc(axis, float_frame, frame_or_series):
3232
# GH 35964
3333
obj = unpack_obj(float_frame, frame_or_series, axis)
3434

3535
with np.errstate(all="ignore"):
3636
f_sqrt = np.sqrt(obj)
3737

3838
# ufunc
39-
result = transform_obj(obj, np.sqrt, axis=axis, series_ops_only=series_ops_only)
39+
result = transform_obj(obj, np.sqrt, axis=axis)
4040
expected = f_sqrt
4141
tm.assert_equal(result, expected)
4242

0 commit comments

Comments
 (0)