-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: crosstab cannot normalize multiple columns for the index #15150
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
@hurcy Thanks for the report! I think the reason is the following: by specifying two columns for the index, a MultiIndex is created (the same problem will arise for the columns). And the normalizing code is not made robust for that, as it tries to access the 'All' column/row, but this isn't present, as in the MultiIndex this is the ('All', '') column/row. Patches to fix is welcome! |
Just ran into the same bug. Possible solution: calling pivot_table in crosstab always with margins=False, then I could try to fix it that way.. |
…based on normalization type, corrected expected margin values in test_margin_dropna
…based on normalization type, corrected expected margin values in test_margin_dropna
This looks fixed in master. Could use a test.
|
Code Sample, a copy-pastable example if possible
Problem description
This gives "ValueError: labels ['All'] not contained in axis"
Currently, crosstab only normalize single index.
I expect crosstab can normalize with multiple columns for the index, but I got ValueError: labels ['All'] not contained in axis.
Expected Output
normalized result
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 2.7.12.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-47-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: None.None
pandas: 0.19.1
nose: None
pip: 9.0.1
setuptools: 28.8.0
Cython: None
numpy: 1.11.2
scipy: 0.18.1
statsmodels: None
xarray: None
IPython: 5.1.0
sphinx: None
patsy: None
dateutil: 2.6.0
pytz: 2016.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.3
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.1.4
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None
None
The text was updated successfully, but these errors were encountered: