Skip to content

Commit

Permalink
BUG: Fixed NDFrame.transform('abs')
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAugspurger committed Apr 23, 2018
1 parent be43dd7 commit cd50adb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pandas/core/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ def get_result(self):

# string dispatch
if isinstance(self.f, compat.string_types):
self.kwds['axis'] = self.axis
if self.f not in {'abs'}:
# Not all transform functions take an axis keyword.
self.kwds['axis'] = self.axis
return getattr(self.obj, self.f)(*self.args, **self.kwds)

# ufunc
Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/frame/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,13 @@ def f():
with np.errstate(all='ignore'):
df.agg({'A': ['abs', 'sum'], 'B': ['mean', 'max']})

def test_transform_abs_name(self):
# https://github.com/pandas-dev/pandas/issues/19760
df = pd.DataFrame({"A": [-1, 2]})
result = df.transform('abs')
expected = pd.DataFrame({"A": [1, 2]})
tm.assert_frame_equal(result, expected)

def test_demo(self):
# demonstration tests
df = pd.DataFrame({'A': range(5), 'B': 5})
Expand Down

0 comments on commit cd50adb

Please sign in to comment.