Groupby Array-Type Quantiles Broken in 0.25.0 · Issue #27526 · pandas-dev/pandas (original) (raw)
Code Sample
import pandas as pd
df = pd.DataFrame({ 'category': ['A', 'A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B', 'B'], 'value': [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6] }) quantiles = df.groupby('category').quantile([0.25, 0.5, 0.75]) print(quantiles)
Problem description
In previous versions of Pandas < 0.25.0
and in the documentation it is possible to pass an array-type of quantiles into the DataFrameGroupBy.quantile()
method to return multiple quantile values in a single call. However, upon installation of 0.25.0
the following error results instead:
Traceback (most recent call last):
File "example.py", line 8, in <module>
quantiles = df.groupby('category').quantile([0.25, 0.5, 0.75])
File "/usr/local/lib/python3.7/site-packages/pandas/core/groupby/groupby.py", line 1908, in quantile
interpolation=interpolation,
File "/usr/local/lib/python3.7/site-packages/pandas/core/groupby/groupby.py", line 2248, in _get_cythonized_result
func(**kwargs) # Call func to modify indexer values in place
File "pandas/_libs/groupby.pyx", line 69
Expected Output
Using Pandas 0.24.2
the output is:
value
category
A 0.25 2.25
0.50 3.50
0.75 4.75
B 0.25 2.25
0.50 3.50
0.75 4.75
Output of pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.7.4.final.0
python-bits : 64
OS : Linux
OS-release : 4.9.125-linuxkit
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 0.25.0
numpy : 1.16.4
pytz : 2019.1
dateutil : 2.8.0
pip : 19.1.1
setuptools : 41.0.1
Cython : None
pytest : 5.0.1
hypothesis : None
sphinx : 2.1.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.10.1
IPython : None
pandas_datareader: None
bs4 : 4.8.0
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.1.1
numexpr : 2.6.9
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : 0.3.0
scipy : 1.3.0
sqlalchemy : None
tables : 3.5.2
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None