-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
Groupby Array-Type Quantiles Broken in 0.25.0 #27526
Comments
I got this error message when using a numpy array (form np.linspace()):
Downgrade to pandas 0.24 solves this. my test code (snipplet):
breaks in last line with 0.25, works in 0.24 |
there is a PR #27473 which solves this and just needs some touching up to fix |
Is the fix to change pandas/pandas/core/groupby/groupby.py Lines 1900 to 1911 in c0ff67a
q , when a list of quintiles is provide? Then concat the results together with concat(results, axis=1, keys=q) ?
|
The output of
In [68]: df = pd.DataFrame({"A": [0, 1, 2, 3, 4]})
In [69]: df.groupby([0, 0, 1, 1, 1]).quantile(0.25)
Out[69]:
A
0 0.25 What's the expected output of It's not the most useful, but I think the best option is a MultiIndex in the columns. In [70]: a = df.iloc[:2].quantile([0.25]).unstack()
In [71]: b = df.iloc[2:].quantile([0.25]).unstack()
In [72]: pd.concat([a, b], keys=[0, 1]).unstack([1, 2])
Out[72]:
A
0.25
0 0.25
1 2.50 The other option is to have the |
Oh, whoops, I missed the 0.24 output. We'll match that. |
Thanks for the fix. I just ran into this! |
* BUG: Fixed groupby quantile for listlike q Closes #27526
not sure if this is the right place,but with 0.25.1 and my code from above i now get a differnet error, but still an error:
the dataframe groupyby objects is looking good, the percs ars a list of floats, including 0 and 1, and the data is the same as it was for the for 0.24.2 version. what am i missing....? |
A new issue with a minimal example would be welcome.
http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports
…On Fri, Aug 23, 2019 at 4:55 AM A. Rabus ***@***.***> wrote:
not sure if this is the right place,but with 0.25.1 and my code from above
i now get a differnet error, but still an error:
quants = g.quantile(percs)
File "/usr/local/miniconda3/envs/scipy37/lib/python3.7/site-packages/pandas/core/groupby/groupby.py", line 1953, in quantile
return result.take(indices)
File "/usr/local/miniconda3/envs/scipy37/lib/python3.7/site-packages/pandas/core/generic.py", line 3604, in take
indices, axis=self._get_block_manager_axis(axis), verify=True
File "/usr/local/miniconda3/envs/scipy37/lib/python3.7/site-packages/pandas/core/internals/managers.py", line 1389, in take
indexer = maybe_convert_indices(indexer, n)
File "/usr/local/miniconda3/envs/scipy37/lib/python3.7/site-packages/pandas/core/indexers.py", line 201, in maybe_convert_indices
raise IndexError("indices are out-of-bounds")
IndexError: indices are out-of-bounds
the dataframe groupyby objects is looking good, the percs ars a list of
floats, including 0 and 1, and the data is the same as it was for the for
0.24.2 version.
what am i missing....?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#27526?email_source=notifications&email_token=AAKAOIXJXN2V6MIM5M7BU2TQF6XX5A5CNFSM4IF5Q76KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD47XRTQ#issuecomment-524253390>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAKAOIRLLMLORKOIJQ3HYQLQF6XX5ANCNFSM4IF5Q76A>
.
|
See #28113
On Fri, Aug 23, 2019 at 6:46 AM Tom Augspurger <tom.augspurger88@gmail.com>
wrote:
… A new issue with a minimal example would be welcome.
http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports
On Fri, Aug 23, 2019 at 4:55 AM A. Rabus ***@***.***> wrote:
> not sure if this is the right place,but with 0.25.1 and my code from
> above i now get a differnet error, but still an error:
>
> quants = g.quantile(percs)
> File "/usr/local/miniconda3/envs/scipy37/lib/python3.7/site-packages/pandas/core/groupby/groupby.py", line 1953, in quantile
> return result.take(indices)
> File "/usr/local/miniconda3/envs/scipy37/lib/python3.7/site-packages/pandas/core/generic.py", line 3604, in take
> indices, axis=self._get_block_manager_axis(axis), verify=True
> File "/usr/local/miniconda3/envs/scipy37/lib/python3.7/site-packages/pandas/core/internals/managers.py", line 1389, in take
> indexer = maybe_convert_indices(indexer, n)
> File "/usr/local/miniconda3/envs/scipy37/lib/python3.7/site-packages/pandas/core/indexers.py", line 201, in maybe_convert_indices
> raise IndexError("indices are out-of-bounds")
> IndexError: indices are out-of-bounds
>
> the dataframe groupyby objects is looking good, the percs ars a list of
> floats, including 0 and 1, and the data is the same as it was for the for
> 0.24.2 version.
>
> what am i missing....?
>
> —
> You are receiving this because you modified the open/close state.
> Reply to this email directly, view it on GitHub
> <#27526?email_source=notifications&email_token=AAKAOIXJXN2V6MIM5M7BU2TQF6XX5A5CNFSM4IF5Q76KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD47XRTQ#issuecomment-524253390>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAKAOIRLLMLORKOIJQ3HYQLQF6XX5ANCNFSM4IF5Q76A>
> .
>
|
* BUG: Fixed groupby quantile for listlike q Closes pandas-dev#27526
sry, just reverted back to 0.24 and went to fix the other issues i have... :-\ |
Code Sample
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 theDataFrameGroupBy.quantile()
method to return multiple quantile values in a single call. However, upon installation of0.25.0
the following error results instead:Expected Output
Using Pandas
0.24.2
the output is: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
The text was updated successfully, but these errors were encountered: