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

Closed
CRP opened this Issue May 25, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@CRP
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

This comment has been minimized.

Show comment
Hide comment
@TomAugspurger

TomAugspurger May 25, 2017

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?

Contributor

TomAugspurger commented May 25, 2017

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?

@CRP

This comment has been minimized.

Show comment
Hide comment
@CRP

CRP May 25, 2017

Contributor

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

Contributor

CRP commented May 25, 2017

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

@CRP CRP referenced this issue in CRP/pandas May 25, 2017

Open

Bugfix 16493 #2

4 of 4 tasks complete

@jreback jreback modified the milestones: 0.20.2, Next Major Release Jun 1, 2017

@jreback jreback closed this in e3ee186 Jun 1, 2017

TomAugspurger added a commit to TomAugspurger/pandas that referenced this issue Jun 1, 2017

BUG: Fixed to_html ignoring index_names parameter
closes #16493

Author: Christian Prinoth <christian@prinoth.name>
Author: Tom Augspurger <tom.w.augspurger@gmail.com>
Author: Christian Prinoth <c.prinoth@CPmbpro.local>
Author: Jeff Reback <jeff.reback@twosigma.com>

This patch had conflicts when merged, resolved by
Committer: Jeff Reback <jeff.reback@twosigma.com>

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)

TomAugspurger added a commit that referenced this issue Jun 4, 2017

BUG: Fixed to_html ignoring index_names parameter
closes #16493

Author: Christian Prinoth <christian@prinoth.name>
Author: Tom Augspurger <tom.w.augspurger@gmail.com>
Author: Christian Prinoth <c.prinoth@CPmbpro.local>
Author: Jeff Reback <jeff.reback@twosigma.com>

This patch had conflicts when merged, resolved by
Committer: Jeff Reback <jeff.reback@twosigma.com>

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 added a commit to Kiv/pandas that referenced this issue Jun 11, 2017

BUG: Fixed to_html ignoring index_names parameter
closes #16493

Author: Christian Prinoth <christian@prinoth.name>
Author: Tom Augspurger <tom.w.augspurger@gmail.com>
Author: Christian Prinoth <c.prinoth@CPmbpro.local>
Author: Jeff Reback <jeff.reback@twosigma.com>

This patch had conflicts when merged, resolved by
Committer: Jeff Reback <jeff.reback@twosigma.com>

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

stangirala added a commit to stangirala/pandas that referenced this issue Jun 11, 2017

BUG: Fixed to_html ignoring index_names parameter
closes #16493

Author: Christian Prinoth <christian@prinoth.name>
Author: Tom Augspurger <tom.w.augspurger@gmail.com>
Author: Christian Prinoth <c.prinoth@CPmbpro.local>
Author: Jeff Reback <jeff.reback@twosigma.com>

This patch had conflicts when merged, resolved by
Committer: Jeff Reback <jeff.reback@twosigma.com>

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment