-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Fixed to_html ignoring index_names parameter #16495
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
Conversation
Thanks. Could you add a test to verify the output is correct? Something simple like df = pd.DataFrame({"A": [1, 2], index=pd.Index(['a', 'b'], name='myindexname'})
result = df.to_html(index_names=False)
assert 'myindexname' not in result You should probably also do some checking that there blank rows aren't put in either. Also need a release not in |
Oh, you'll also need to use |
ok, sorry, was a bit too hasty. please check the new pull request.
…On Thu, May 25, 2017 at 3:31 PM, Tom Augspurger ***@***.***> wrote:
Oh, you'll also need to use self.fmt.show_index_names (need the .fmt in
there). For reference, most (all?) of the common DataFrame formatting
arguments are bundled into a DataFrameFormatter, which is then passed as
the first argument to HTMLFormatter.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#16495 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAxTkORU50RSmLEDmMBEy8ugUNCRFTkLks5r9YKpgaJpZM4NmWv6>
.
--
Christian Prinoth
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, looks like it's saved as show_index_names
on DataFrameFormatter
, not index_names
.
FYI you can test it locally with pytest pandas/tests/io/formats/test_to_html.py -k test_to_html_with_index_names_false
. It also looks like that line is too long: https://travis-ci.org/pandas-dev/pandas/jobs/236007626#L2829
doc/source/whatsnew/v0.20.2.txt
Outdated
@@ -59,6 +59,7 @@ I/O | |||
- Bug in pd.read_csv() when comment is passed in space deliminted text files (:issue:`16472`) | |||
- Bug that would force importing of the clipboard routines unnecessarily, potentially causing an import error on startup (:issue:`16288`) | |||
- Bug that raised IndexError HTML-rendering an empty DataFrame (:issue:`15953`) | |||
- Bug where to_html ignored the index_names parameter (:issue:`16493`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to_html to
``DataFrame.to_html``
and put index_names in double backticks
I used show_index_names on purpose, based on this line:
[image: Inline image 1]
should line 372 be modified as well for consistency with the parameter name?
…On Thu, May 25, 2017 at 6:33 PM, Tom Augspurger ***@***.***> wrote:
***@***.**** commented on this pull request.
Sorry, looks like it's saved as show_index_names on DataFrameFormatter,
not index_names.
FYI you can test it locally with pytest pandas/tests/io/formats/test_to_html.py
-k test_to_html_with_index_names_false. It also looks like that line is
too long: https://travis-ci.org/pandas-dev/pandas/jobs/236007626#L2829
------------------------------
In doc/source/whatsnew/v0.20.2.txt
<#16495 (comment)>:
> @@ -59,6 +59,7 @@ I/O
- Bug in pd.read_csv() when comment is passed in space deliminted text files (:issue:`16472`)
- Bug that would force importing of the clipboard routines unnecessarily, potentially causing an import error on startup (:issue:`16288`)
- Bug that raised IndexError HTML-rendering an empty DataFrame (:issue:`15953`)
+- Bug where to_html ignored the index_names parameter (:issue:`16493`)
Change to_html to
``DataFrame.to_html``
and put index_names in double backticks
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#16495 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAxTkBwtcWgWwtMK5vtuZtMIeoUyn9qhks5r9a1bgaJpZM4NmWv6>
.
--
Christian Prinoth
|
Your image didn't show up, so I don't know what lines you're referring to. You shouldn't have to change any parameter names. I must have been confused though. The current version is correct (the line might be too long though. Try |
Codecov Report
@@ Coverage Diff @@
## master #16495 +/- ##
=======================================
Coverage 90.43% 90.43%
=======================================
Files 161 161
Lines 51045 51045
=======================================
Hits 46161 46161
Misses 4884 4884
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #16495 +/- ##
==========================================
+ Coverage 90.43% 90.79% +0.36%
==========================================
Files 161 161
Lines 51045 51063 +18
==========================================
+ Hits 46161 46365 +204
+ Misses 4884 4698 -186
Continue to review full report at Codecov.
|
what I meant is that the name of parameter of the to_html method is
"index_names". Internally, in the fmt structure, it is renamed
"show_index_names", which I then use to determine whether relevant header
row should be included in the html table.
I fixed the line too long by replacing with all(...) and splitting content
of statement on several lines.
…On Thu, May 25, 2017 at 7:21 PM, Tom Augspurger ***@***.***> wrote:
Your image didn't show up, so I don't know what lines you're referring to.
You shouldn't have to change any parameter names. I must have been
confused though. The current version is correct (the line might be too long
though. Try flake8 pandas/io/formats/format.py to make sure)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#16495 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAxTkCFVXJMcYmjNAZgT08zZaDQWn8DLks5r9biHgaJpZM4NmWv6>
.
--
Christian Prinoth
|
Sounds good. Looks like a small issue with the usage of `all`:
https://travis-ci.org/pandas-dev/pandas/jobs/236274960#L1522
if all(self.fmt.has_index_names,
self.fmt.index,
self.fmt.show_index_names):
It takes an iterable of booleans. So something like
```python
if all((self.fmt.has_index_names,
self.fmt.index,
self.fmt.show_index_names)):
```
On Fri, May 26, 2017 at 2:17 AM, Christian Prinoth <[email protected]
… wrote:
what I meant is that the name of parameter of the to_html method is
"index_names". Internally, in the fmt structure, it is renamed
"show_index_names", which I then use to determine whether relevant header
row should be included in the html table.
I fixed the line too long by replacing with all(...) and splitting content
of statement on several lines.
On Thu, May 25, 2017 at 7:21 PM, Tom Augspurger ***@***.***>
wrote:
> Your image didn't show up, so I don't know what lines you're referring
to.
>
> You shouldn't have to change any parameter names. I must have been
> confused though. The current version is correct (the line might be too
long
> though. Try flake8 pandas/io/formats/format.py to make sure)
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#16495 (comment)
>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/
AAxTkCFVXJMcYmjNAZgT08zZaDQWn8DLks5r9biHgaJpZM4NmWv6>
> .
>
--
Christian Prinoth
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#16495 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHIk1akgdSoB5zNBsxUOIiTH8E2waKks5r9nyNgaJpZM4NmWv6>
.
|
done and pushed. You certainly are a patient guy ;)
On Fri, May 26, 2017 at 1:42 PM, Tom Augspurger <[email protected]>
wrote:
… Sounds good. Looks like a small issue with the usage of `all`:
https://travis-ci.org/pandas-dev/pandas/jobs/236274960#L1522
if all(self.fmt.has_index_names,
self.fmt.index,
> self.fmt.show_index_names):
It takes an iterable of booleans. So something like
```python
if all((self.fmt.has_index_names,
self.fmt.index,
self.fmt.show_index_names)):
```
On Fri, May 26, 2017 at 2:17 AM, Christian Prinoth <
***@***.***
> wrote:
> what I meant is that the name of parameter of the to_html method is
> "index_names". Internally, in the fmt structure, it is renamed
> "show_index_names", which I then use to determine whether relevant header
> row should be included in the html table.
>
> I fixed the line too long by replacing with all(...) and splitting
content
> of statement on several lines.
>
> On Thu, May 25, 2017 at 7:21 PM, Tom Augspurger <
***@***.***>
> wrote:
>
> > Your image didn't show up, so I don't know what lines you're referring
> to.
> >
> > You shouldn't have to change any parameter names. I must have been
> > confused though. The current version is correct (the line might be too
> long
> > though. Try flake8 pandas/io/formats/format.py to make sure)
> >
> > —
> > You are receiving this because you authored the thread.
> > Reply to this email directly, view it on GitHub
> > <#16495#
issuecomment-304068837
> >,
> > or mute the thread
> > <https://github.com/notifications/unsubscribe-auth/
> AAxTkCFVXJMcYmjNAZgT08zZaDQWn8DLks5r9biHgaJpZM4NmWv6>
> > .
> >
>
>
>
> --
>
> Christian Prinoth
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#16495 (comment)
>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/
ABQHIk1akgdSoB5zNBsxUOIiTH8E2waKks5r9nyNgaJpZM4NmWv6>
> .
>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#16495 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAxTkPThnPifm9cu86Rkt0uj66QyXEHwks5r9rqlgaJpZM4NmWv6>
.
--
Christian Prinoth
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. minor comment.
@@ -1869,3 +1869,9 @@ def test_to_html_notebook_has_no_style(self): | |||
df = pd.DataFrame({"A": [1, 2, 3]}) | |||
result = df.to_html() | |||
assert "thead tr:only-child" not in result | |||
|
|||
def test_to_html_with_index_names_false(self): | |||
df = pd.DataFrame({"A": [1, 2]}, index=pd.Index(['a', 'b'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add the issue reference as a comment.
doc/source/whatsnew/v0.20.2.txt
Outdated
@@ -59,6 +59,7 @@ I/O | |||
- Bug in pd.read_csv() when comment is passed in space deliminted text files (:issue:`16472`) | |||
- Bug that would force importing of the clipboard routines unnecessarily, potentially causing an import error on startup (:issue:`16288`) | |||
- Bug that raised IndexError HTML-rendering an empty DataFrame (:issue:`15953`) | |||
- Bug where ``DataFrame.to_html`` ignored the ``index_names`` parameter (:issue:`16493`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DataFrame.to_html()
@CRP make sure to pull this branch before pushing those fixes. I pushed a commit fixing a small lint error. |
sorry you lost me, what else do i need to do to close this issue?
…On Wed, May 31, 2017 at 4:41 AM, Tom Augspurger ***@***.***> wrote:
@CRP <https://github.com/crp> make sure to pull this branch before
pushing those fixes. I pushed a commit fixing a small lint error.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#16495 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAxTkNcnCBSRTYn8xLqeJu-1cKCrbPRGks5r_NNKgaJpZM4NmWv6>
.
--
Christian Prinoth
|
thanks! |
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)
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)
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
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
git diff upstream/master --name-only -- '*.py' | flake8 --diff