-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH:AttributeError: 'SeriesGroupBy' object has no attribute 'kurtosis' #40139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I don't believe SeriesGroupBy is documented as having a kurtosis method. Are you finding something different? |
You are right... it just tripped me up that first three moments are implemented, but not the fourth one. |
+1 on adding, I think this would just be adding to the common_apply_allowlist. In the meantime, from https://stackoverflow.com/questions/37345493/kurtosis-on-groupby-of-pandas-dataframe-doesnt-work
This is essentially what is occurring under the hood for skew. Might want to use pd.Series instead of pd.DataFrame here. |
Can't believe this is still a thing. mean, std, skew, count, min, max, median all other things work but not kurtosis? I mean.. why? |
@jaepil-choi - PRs are welcome! |
Found out that pd.DataFrame.kurt workaround works. Would a very basic temporary fix like simply converting 'kurt' to pd.DataFrame.kurt get passed and merged? |
I believe you can implement this similar to SeriesGroupBy: pandas/pandas/core/groupby/generic.py Lines 1413 to 1423 in c47296a
DataFrameGroupBy: pandas/pandas/core/groupby/generic.py Lines 2894 to 2904 in c47296a
A PR would need the right arguments and tests. |
take |
take |
take |
@rhshadrach I raised a PR for this - #60433. Could you please review? Thanks. |
Code Sample, a copy-pastable example
Problem description
Code gives error:
AttributeError: 'SeriesGroupBy' object has no attribute 'kurtosis'
instead of correct group-wise kurtosis.Skew works ok.
Expected Output
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
The text was updated successfully, but these errors were encountered: