-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
initial HTML rendering for Series #29248
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
) | ||
return formatter.to_html(notebook=True) | ||
else: | ||
return None |
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.
should this warn/raise?
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.
Not sure - I just copied this behaviour from DataFrame._repr_html_()
for consistency. Happy to change it if preferred, but if we do that then should the DataFrame behaviour also be changed?
@@ -226,7 +226,79 @@ def to_string(self) -> str: | |||
return str("\n".join(result)) | |||
|
|||
|
|||
class SeriesFormatter: | |||
class TableFormatter: |
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.
is there a reason this is moved up from below?
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.
Yes - the SeriesFormatter now inherits from TableFormatter, meaning it needs to be declared first.
Can you add test(s) for this |
Any chance you took a look at #27228 prior to this? Haven't reviewed in detail yet but just surprised this is a much larger change than that one. May or may not be an issue just curious |
Yes I can see why - the implementation by @mrocklin is just calling Edit: This PR also adds in support for to_html, rather than just repr_html. I'll freely admit that there's a lot of repeated code between the SeriesFormatter and the DataFrameFormatter - I think that if the DataFrameFormatter was refactored into something more generic then most of this duplication could be removed, making the PR a lot smaller. But I only had a few hours to spare on this hence not wanting to make too many changes to existing code, especially on a project I've never done any dev work on before. The only other difference really is the aesthetics. In my impl, the footer information sits outside of the HTML table rather than within it. It also uses some different formatting to highlight different bits of information: If you'd rather see the extra refactoring done to reduce the total amount of code then that's probably more effort than I can afford right now, but if you're happy with the current approach then I can do the remaining work needed to fix old/add new unit tests. Alternatively, if you prefer the appearance of my solution but the smaller footprint of the other PR, then I could modify that PR to use my footer logic instead. |
The problem with a PR of this size is that it is difficult to review and adds a lot of code duplication. If there is no way to do this without copy / pasting a lot of code, can you alternately just try to implement |
That's understandable, but I don't think my changes would be much different by implementing just If you'd prefer a smaller change to start with, I think #27228 is basically what you'd end up with. If you'd like me to contribute what you see in the screenshots above, I'd say the best way is to branch off #27228 and make some small changes to it. I'd be happy to do this if you agree that's a good way forward? I should also add that I'm sure it is possible to do the complete piece of work without the code duplication, but I don't have the time or the knowledge of the existing code to do that right now. |
Yea I would suggest that first. It seems to be in line with what the commentary was on that PR was as well, that just that one piece first would make sense instead of tackling all at once |
Have submitted a new PR based on this conversation, #29383, to supercede this one. |
Added to_html() and repr_html() to Series class.
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff