Skip to content
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

MultiIndex Column Offset Bug with to_html(index=False) #8452

Closed
woztheproblem opened this issue Oct 3, 2014 · 2 comments
Closed

MultiIndex Column Offset Bug with to_html(index=False) #8452

woztheproblem opened this issue Oct 3, 2014 · 2 comments
Labels
Bug IO HTML read_html, to_html, Styler.apply, Styler.applymap Output-Formatting __repr__ of pandas objects, to_string
Milestone

Comments

@woztheproblem
Copy link

I'm trying to use to_html() to print a DataFrame that has a MultiIndex column, and I want to hide the index. When I do, the column labels are shifted right by one column. I use:

import pandas as pd
from IPython.display import HTML
df = pd.DataFrame({'a': range(10), 'b': range(10,20), 'c': range(10,20), 'd': range(10,20)})
df.columns = pd.MultiIndex.from_product([['a', 'b'], ['c', 'd']])
HTML(df.to_html(index=False))

and the result is:
screen shot 2014-10-03 at 10 45 31 am

Seems to me to_html() isn't properly accounting for the index=False when there is a column Multindex. With single-level column index ( df.columns=list('abcd') ) it prints fine. With index=True, to_html() also works fine.

My versions are:

INSTALLED VERSIONS

commit: None
python: 2.7.8.final.0
python-bits: 64
OS: Darwin
OS-release: 13.3.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.14.1
nose: 1.3.3
Cython: 0.20.1
numpy: 1.9.0
scipy: 0.14.0
statsmodels: 0.5.0
IPython: 2.1.0
sphinx: 1.2.2
patsy: 0.2.1
scikits.timeseries: None
dateutil: 2.2
pytz: 2014.7
bottleneck: None
tables: 3.1.1
numexpr: 2.3.1
matplotlib: 1.3.1
openpyxl: 1.8.5
xlrd: 0.9.3
xlwt: 0.7.5
xlsxwriter: 0.5.5
lxml: 3.3.5
bs4: 4.3.1
html5lib: None
httplib2: None
apiclient: None
rpy2: None
sqlalchemy: 0.9.4
pymysql: None
psycopg2: None

dxe4 added a commit to dxe4/pandas that referenced this issue Dec 6, 2014
@jreback jreback added Bug Output-Formatting __repr__ of pandas objects, to_string IO HTML read_html, to_html, Styler.apply, Styler.applymap labels Dec 6, 2014
@jreback jreback added this to the 0.15.2 milestone Dec 6, 2014
@jreback
Copy link
Contributor

jreback commented Dec 7, 2014

closed by #9018

@jreback jreback closed this as completed Dec 7, 2014
@woztheproblem
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO HTML read_html, to_html, Styler.apply, Styler.applymap Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

No branches or pull requests

2 participants