You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, when this key-only Grouper is passed to groupby inside a list, a TypeError is thrown. The following example is for a scalar list containing the same Grouper object as in the previous example.
This probably should work, thanks for the report! But I'm curious, why are using a Grouper in this case instead of df.groupby(['A']), df.groupby(['A','B']), etc?
I'm in the process of working on implementing #5677 which will allow the A in df.groupby(['A']) to refer to an index level in df named A if df has no column named A. Per the conversation in #5677, If a frame has both a column named A and an index level named A then df.groupby(['A']) will group by the column (this maintains backwards compatibility). I came across this bug in the process of writing tests to verify that this ambiguity is resolved properly.
…d to groupby in a list (GH14334)
closespandas-dev#14334
Author: Jon M. Mease <[email protected]>
Closespandas-dev#14342 from jmmease/bug_14334 and squashes the following commits:
5e96797 [Jon M. Mease] Add tests for grouping on two columns
cee5ce6 [Jon M. Mease] Added bug description to new test case
f9ef05b [Jon M. Mease] Moved whatsnew to 0.19.1 and clarified description
14a4ae6 [Jon M. Mease] Added whatsnew for GH 14334
9805c30 [Jon M. Mease] Fix for GH 14334
dfd3e09 [Jon M. Mease] Added test case for GH 14334
(cherry picked from commit 4852008)
Overview
A
Grouper
object configured with only akey
specification may be passed togroupby
to group a DataFrame by a particular column. For example:However, when this key-only
Grouper
is passed togroupby
inside a list, aTypeError
is thrown. The following example is for a scalar list containing the sameGrouper
object as in the previous example.The same error occurs for lists containing multiple key-only
Groupers
. e.g.[pd.Grouper(key='A'), pd.Grouper(key='B')]
Expected Output
Output of
pd.show_versions()
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Darwin
OS-release: 15.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
pandas: 0.18.1
nose: 1.3.7
pip: 8.1.2
setuptools: 23.0.0
Cython: 0.24
numpy: 1.11.1
scipy: 0.17.1
statsmodels: 0.6.1
xarray: None
IPython: 4.2.0
sphinx: 1.4.1
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.4
blosc: 1.4.1
bottleneck: 1.1.0
tables: 3.2.2
numexpr: 2.6.0
matplotlib: 1.5.1
openpyxl: 2.3.2
xlrd: 1.0.0
xlwt: 1.1.2
xlsxwriter: 0.9.2
lxml: 3.6.0
bs4: 4.4.1
html5lib: 0.999
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.40.0
pandas_datareader: None
The text was updated successfully, but these errors were encountered: