ENH: #8750 add Series support for to_html and _repr_html_
State: closed

closes #5563


Labels:
name: Output-Formatting
description: __repr__ of pandas objects, to_string
name: IO HTML
description: read_html, to_html, Styler.apply, Styler.applymap

Comments:
@lexual Could you add a image showing what the new `_repr_html_` looks like for Series? The main challenge here is that we'd like to be sure it remains clearly visually distinct from that for DataFrame.

Looking through your code, I see that you are basically just calling `s.to_frame()._repr_html()`. This is a bit of a non-starter -- we need something that is obviously different. Users should know when they're working with a series instead of a frame.

@lexual can you rebase & add a whatsnew note.

@lexual can you update according to comments

@lexual like to put this in 0.17.1. can you rebase/update

@jreback Given the last comment of @shoyer above (https://github.com/pydata/pandas/pull/10300#issuecomment-109693262), I don't think this is ready for inclusion in 0.17.1. We should first figure out how we want it to look like (needs to be a distinction from dataframe with one column)

@jreback have rebased, let us know if merge-able, or needs reworking ;)

Can you show how the output looks like?

@lexual I think we _would_ like to put this in, but I agree that it can't look like a 1-column frame, maybe same but no header?

@lexual can you show a render of this?

can you update

@lexual can you update?

@lexual can you rebase / update

can you rebase/update.

@lexual can you rebase / update

can you rebase / update?

It's nice if you can meet v0.19.0. Otherwise allow me to work this on.

Closing this, @sinhrks I think you can go ahead (or rebase this one). But see also the comments above that are not yet resolved I think from @shoyer and me:

> I see that you are basically just calling s.to_frame()._repr_html(). This is a bit of a non-starter -- we need something that is obviously different. Users should know when they're working with a series instead of a frame.
> 
> We should first figure out how we want it to look like (needs to be a distinction from dataframe with one column)

Apologies haven't been able to respond or rebase as requested in the past.

Did this get merged, or just closed?

Does it need major surgery to get merged, or just rebase & possibly tidy up?

Thanks ;)

I don't think @sinhrks has started on this yet, but he can tell you for sure. It has not been merged but was closed because it was stale. If you are interested in working on this again we can reopen.

The important thing to figure out first (maybe in the linked issue) is what the HTML repr should actually look like.

The styling of HTML tables in the jupyter notebook is provided by the jupyter CSS itself. From this perspective, the HTMl repr simply needs to have a well formed table format with `tbody` and `thead` blocks. Should be very simple. Also we should test on the new table styling that is in master of jupyter and jupyterlab...

@ellisonbg Technically there is indeed no problem, just having `_repr_html` output a well behaved html snippet. 
The issue is more 'design'-related, as we do _not_ want it to look just like a normal table, as in that case it would not distinguish well from a one-column dataframe. Maybe not that difficult, but up to now nobody put forward a concrete proposal for how it could look like.