Closed
Description
Code Sample
import numpy
import pandas
numpy.random.seed(1234)
frame = pandas.DataFrame(
data=numpy.random.random((5, 3))
)
print(
frame
)
# Works
print(
frame.agg(['mean', 'std'])
)
# Expected output
print(
frame.transpose().agg(['mean', 'std']).transpose()
)
# Does not work as expected
print(
frame.agg(['mean', 'std'], axis=1)
)
Problem description
Calling the agg
method on a frame with axis=1
raises a TypeError
:
Traceback (most recent call last):
File "/home/lafras/tmp/buggy.py", line 13, in <module>
frame.agg(['mean', 'std'], axis=1)
File "/home/lafras/.local/lib/python3.5/site-packages/pandas/core/frame.py", line 4154, in aggregate
return self.apply(func, axis=axis, args=args, **kwargs)
File "/home/lafras/.local/lib/python3.5/site-packages/pandas/core/frame.py", line 4262, in apply
ignore_failures=ignore_failures)
File "/home/lafras/.local/lib/python3.5/site-packages/pandas/core/frame.py", line 4358, in _apply_standard
results[i] = func(v)
TypeError: ("'list' object is not callable", 'occurred at index 0')
Expected Output
frame.agg(['mean', 'std'], axis=1)
should produce this:
mean std
0 0.417119 0.216033
1 0.612642 0.294504
2 0.678825 0.357107
3 0.578248 0.267557
4 0.588805 0.189838
Output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-79-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_ZA.UTF-8
LOCALE: en_ZA.UTF-8
pandas: 0.20.2
pytest: 3.0.4
pip: 9.0.1
setuptools: 36.0.1
Cython: 0.25.2
numpy: 1.13.0
scipy: 0.19.0
xarray: 0.8.2
IPython: 6.1.0
sphinx: None
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: None
tables: 3.3.0
numexpr: 2.6.1
feather: None
matplotlib: 2.0.0
openpyxl: None
xlrd: 1.0.0
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.4.1
html5lib: 0.9999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.5
s3fs: 0.0.7
pandas_gbq: None
pandas_datareader: 0.2.1