Skip to content

to_html(index_names=False) still renders a row with index names #16493

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

Closed
CRP opened this issue May 25, 2017 · 2 comments · May be fixed by CRP/pandas#2
Closed

to_html(index_names=False) still renders a row with index names #16493

CRP opened this issue May 25, 2017 · 2 comments · May be fixed by CRP/pandas#2
Labels
Bug IO HTML read_html, to_html, Styler.apply, Styler.applymap Output-Formatting __repr__ of pandas objects, to_string
Milestone

Comments

@CRP
Copy link
Contributor

CRP commented May 25, 2017

The index_names parameter is apparently ignored.
I tried to debug the code, and it looks like line 1291 of pandas/io/formats/format.py should contain "and self.fmt.show_index_names" in the if clause.

here is sample code:

x=DataFrame(np.random.randn(3,4),columns=list('abcd'))
x.index.name='pippo'
print(x.to_html(index_names=False))

which produces the following output:

a b c d
pippo
0 1.715511 -1.582624 0.027399 -0.276980
1 -0.003603 -1.227605 0.434763 0.039167
2 0.246343 -0.062897 -0.724532 -0.352672

the second row of the thead should not be there...

INSTALLED VERSIONS ------------------ commit: None python: 3.6.1.final.0 python-bits: 64 OS: Darwin OS-release: 16.6.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: en_US.UTF-8 LANG: en_US.UTF-8 LOCALE: en_US.UTF-8

pandas: 0.20.1
pytest: None
pip: 9.0.1
setuptools: 35.0.2
Cython: None
numpy: 1.12.1
scipy: 0.19.0
xarray: 0.9.5
IPython: 6.0.0
sphinx: None
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: None
tables: 3.4.2
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: 2.4.7
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: 0.9.6
lxml: None
bs4: None
html5lib: 0.999999999
sqlalchemy: 1.1.9
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: None

@TomAugspurger
Copy link
Contributor

May be as simple as also checking self.fmt.index_names in

if self.fmt.has_index_names and self.fmt.index:
(and tests).

@CRP interested in submitting a fix?

@TomAugspurger TomAugspurger added Bug IO HTML read_html, to_html, Styler.apply, Styler.applymap Output-Formatting __repr__ of pandas objects, to_string labels May 25, 2017
@TomAugspurger TomAugspurger added this to the Next Major Release milestone May 25, 2017
@CRP
Copy link
Contributor Author

CRP commented May 25, 2017

just created pull request, not sure if I did everything right...

@CRP CRP mentioned this issue May 25, 2017
4 tasks
@jreback jreback modified the milestones: 0.20.2, Next Major Release Jun 1, 2017
@jreback jreback closed this as completed in e3ee186 Jun 1, 2017
TomAugspurger pushed a commit to TomAugspurger/pandas that referenced this issue Jun 1, 2017
closes pandas-dev#16493

Author: Christian Prinoth <[email protected]>
Author: Tom Augspurger <[email protected]>
Author: Christian Prinoth <[email protected]>
Author: Jeff Reback <[email protected]>

This patch had conflicts when merged, resolved by
Committer: Jeff Reback <[email protected]>

Closes pandas-dev#16495 from CRP/bugfix_16493 and squashes the following commits:

567ae69 [Jeff Reback] doc corrections
8429f9a [Tom Augspurger] Fixed lint error
469a0e6 [Christian Prinoth] BUG: fix for bug 16493
20d512f [Christian Prinoth] BUG: fix for bug 16493
6bef829 [Christian Prinoth] BUG: fix for bug 16493
426565e [Christian Prinoth] BUG: fix for bug 16493
a40820d [Christian Prinoth] BUG: fix for bug 16493

(cherry picked from commit e3ee186)
TomAugspurger pushed a commit that referenced this issue Jun 4, 2017
closes #16493

Author: Christian Prinoth <[email protected]>
Author: Tom Augspurger <[email protected]>
Author: Christian Prinoth <[email protected]>
Author: Jeff Reback <[email protected]>

This patch had conflicts when merged, resolved by
Committer: Jeff Reback <[email protected]>

Closes #16495 from CRP/bugfix_16493 and squashes the following commits:

567ae69 [Jeff Reback] doc corrections
8429f9a [Tom Augspurger] Fixed lint error
469a0e6 [Christian Prinoth] BUG: fix for bug 16493
20d512f [Christian Prinoth] BUG: fix for bug 16493
6bef829 [Christian Prinoth] BUG: fix for bug 16493
426565e [Christian Prinoth] BUG: fix for bug 16493
a40820d [Christian Prinoth] BUG: fix for bug 16493

(cherry picked from commit e3ee186)
Kiv pushed a commit to Kiv/pandas that referenced this issue Jun 11, 2017
closes pandas-dev#16493

Author: Christian Prinoth <[email protected]>
Author: Tom Augspurger <[email protected]>
Author: Christian Prinoth <[email protected]>
Author: Jeff Reback <[email protected]>

This patch had conflicts when merged, resolved by
Committer: Jeff Reback <[email protected]>

Closes pandas-dev#16495 from CRP/bugfix_16493 and squashes the following commits:

567ae69 [Jeff Reback] doc corrections
8429f9a [Tom Augspurger] Fixed lint error
469a0e6 [Christian Prinoth] BUG: fix for bug 16493
20d512f [Christian Prinoth] BUG: fix for bug 16493
6bef829 [Christian Prinoth] BUG: fix for bug 16493
426565e [Christian Prinoth] BUG: fix for bug 16493
a40820d [Christian Prinoth] BUG: fix for bug 16493
stangirala pushed a commit to stangirala/pandas that referenced this issue Jun 11, 2017
closes pandas-dev#16493

Author: Christian Prinoth <[email protected]>
Author: Tom Augspurger <[email protected]>
Author: Christian Prinoth <[email protected]>
Author: Jeff Reback <[email protected]>

This patch had conflicts when merged, resolved by
Committer: Jeff Reback <[email protected]>

Closes pandas-dev#16495 from CRP/bugfix_16493 and squashes the following commits:

567ae69 [Jeff Reback] doc corrections
8429f9a [Tom Augspurger] Fixed lint error
469a0e6 [Christian Prinoth] BUG: fix for bug 16493
20d512f [Christian Prinoth] BUG: fix for bug 16493
6bef829 [Christian Prinoth] BUG: fix for bug 16493
426565e [Christian Prinoth] BUG: fix for bug 16493
a40820d [Christian Prinoth] BUG: fix for bug 16493
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
3 participants