ENH:AttributeError: 'SeriesGroupBy' object has no attribute 'kurtosis' · Issue #40139 · pandas-dev/pandas (original) (raw)

Code Sample, a copy-pastable example

df = pd.DataFrame({'birb':['Falcon', 'Falcon', 'Falcon', 'Falcon', 'Parrot', 'Parrot', 'Parrot', 'Parrot'], 'value': [390., 350.,390., 350., 30., 20., 30., 20.]}) df.groupby('birb').aggregate({'value': ['count', 'mean', 'skew']})

Problem description

Code gives error: AttributeError: 'SeriesGroupBy' object has no attribute 'kurtosis' instead of correct group-wise kurtosis.
Skew works ok.

Expected Output

       value            
       count   mean kurtosis
birb                    
Falcon     4  370.0  -6.0
Parrot     4   25.0  -6.0

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 7d32926
python : 3.7.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-66-generic
Version : #74~18.04.2-Ubuntu SMP Fri Feb 5 11:17:31 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_IE.UTF-8
LOCALE : en_IE.UTF-8

pandas : 1.2.2
numpy : 1.17.5
pytz : 2021.1
dateutil : 2.8.1
pip : 21.0.1
setuptools : 49.2.1
Cython : None
pytest : 5.3.5
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.20.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.4
numexpr : None
odfpy : None
openpyxl : 3.0.6
pandas_gbq : None
pyarrow : 3.0.0
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : 0.52.0