-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Adding Series._repr_html_ #16888
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
Adding Series._repr_html_ #16888
Conversation
can you add some tests. also pls show a screen shot (with a series & dataframe of same) |
Here's a demo that shows what it looks like. https://github.com/AllenDowney/pandas/blob/master/series_html_demo.ipynb |
can you update your notebook to add name to the Series, and names to the indexes (both for Series and DataFrame), just to show where they are printing. |
The current version strips the header, so if the series has a name or if the index of the series has a name, they don't appear. Assuming that's not the desired behavior, let's talk about what the desired behavior is. Would you agree:
In that case, maybe a different approach would be to change the style of the table rather than the content. What do we think of:
So the visual distinction is that DataFrames will have borders and Series will not. Thoughts? |
Ok, I think that's doable. But I have a question about implementing it.
Currently I am calling DataFrame._repr_html_ to generate HTML for the
Series and then modifying the result to specialize it for Series.
If I am making small changes, I can do that with regular expressions, but
for something more substantial, it would be better to parse the HTML and
modify the tree.
So, how bad would it be to use lxml in Series._repr_html_? Or is there
another HTML parser you'd recommend?
…On Wed, Jul 12, 2017 at 12:43 PM, Tom Augspurger ***@***.***> wrote:
I think the name and dtype in a caption at the bottom would be preferred.
Something like
[image: screen shot 2017-07-12 at 11 41 54 am]
<https://user-images.githubusercontent.com/1312546/28128963-2219e6fa-66f7-11e7-8d05-9beb7fe912f7.png>
(with better styling of course). Since DataFrames put the column names
above, I think this will be visually distinct enough.
If the index is named, that can stay in the table header.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#16888 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABy37ed77SuM-tJUmyAHbyC-BQJkOJaNks5sNPe8gaJpZM4OU8jp>
.
|
BTW is anyone at SciPy and interested in talking about this or working on it? |
@AllenDowney yeah that'd be great. I'm in the lightning talks right now, but perhaps we can sit down sometime later in the week? |
I think the impl should follow how we do DataFrame output itself. It might be a bit of code duplication, but way more flexibility that post-processing the html. |
@TomAugspurger and @phobson and I spoke this afternoon. We are leaning toward a quick implementation by calling @jreback, you are right that a real implementation would be better, but I think this is a case where a good enough solution is very easy, and the best solution is substantially harder. |
closing as stale. I think we need a full fledged impl here. |
Whoops, this one fell off my radar. I think we had a decent way that avoids too much duplication. I'll see if I can find that branch. |
ok feel free to reopen |
This is intended to close #5563 by adding
Series._repr_html_
As suggested by previous discussion, the HTML representation of a Series looks different from the representation of a DataFrame, specifically by omitting the
<thead>
row, which (for a DataFrame) contains the column names.I've tested it in a Jupyter notebook; I can provide a screenshot if someone suggests the best way to do that.
git diff upstream/master --name-only -- '*.py' | flake8 --diff
(On Windows,git diff upstream/master -u -- "*.py" | flake8 --diff
might work as an alternative.)