Adding Series._repr_html_
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.


- [ ] closes #5563
 - [ ] tests added / passed
 - [ ] passes ``git diff upstream/master --name-only -- '*.py' | flake8 --diff`` (On Windows, ``git diff upstream/master -u -- "*.py" | flake8 --diff`` might work as an alternative.)
 - [ ] whatsnew entry

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](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:

1.  If the series has a name, it should appear.
2.  If the index of the series has a name, it should appear.
3. The HTML representation of a Series should look different from a DataFrame.

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:

1.  Adding a border to the HTML repr of a DataFrame.
2.  Omit the border for a Series.

So the visual distinction is that DataFrames will have borders and Series will not.

Thoughts? I think the name and dtype in a caption at the bottom would be preferred. Something like

<img width="222" alt="screen shot 2017-07-12 at 11 41 54 am" src="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. 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 <notifications@github.com>
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
> <https://github.com/pandas-dev/pandas/pull/16888#issuecomment-314827583>,
> 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 `DataFrame._repr_html_` and then making changes to the HTML.  Not using lxml, though; that definitely seems like overkill.  But with just a few lines of code we can add a caption with the name of the Series and the dtype, and it should be pretty robust.

@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