-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat(python): Add DataFrame.style
namespace
#16809
Conversation
@MarcoGorelli Could you review this one? Seems very similar to the plotting one. Ideally I like the same non-stable guarantees and ofcourse lazy imports. Thank you @machow for the PR. |
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.
Personally, I love this. I read recently someone on Reddit write
pandas still has a lot of features that aren't present in polars, table styling being the one I use the most
and if there's such an easy to get native Polars styling, I'm all for it.
The tables look really nice, and being able to pass expressions and selectors in is the icing the cake
could you run make pre-commit
please?
I'm noticing now that polars supports python >= 3.8. Great Tables currently supports python >= 3.9 (we've loosely been following NEP 29). I'm happy to do whatever seems useful here (as I recall, restoring python 3.8 support to Great Tables is largely an issue of tweaking type annotations) |
Co-authored-by: Marco Edward Gorelli <marcogorelli@protonmail.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16809 +/- ##
==========================================
+ Coverage 81.33% 81.42% +0.09%
==========================================
Files 1424 1425 +1
Lines 187172 187973 +801
Branches 2697 2708 +11
==========================================
+ Hits 152235 153060 +825
+ Misses 34441 34415 -26
- Partials 496 498 +2 ☔ View full report in Codecov by Sentry. |
Alright--it looks like merging in the python>=3.9 in requirements.txt did the trick! Happy to do anything else useful! |
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.
Amazing
Granted, I'm a bit biased, because I did suggest that Michael do this, but I am really impressed with GreatTables:
- they support Polars directly (no conversion to other dataframes necessary)
- they accept Polars expressions and selectors as part of their API, making it feel really natural to users
- as mentioned earlier, some users complain about lack of styling in Polars
- their tables just look really good
- it's low-maintenance on the Polars side. And if it doesn't work out for some reason, it's marked as unstable anyway. But my expectation is that people will love it
So, I'm really in favour
(you are missing a note in docs/user-guide/installation.md though) |
Ah thanks for the quick review, and catching the installation page! I did a lot of grepping for hvplot and pydantic, but the word "plot" slipped under the radar 😓. Added a style note to installation |
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.
Thank you @machow for the PR and thanks for the review @MarcoGorelli!
DataFrame.style
namespace
Based on conversation with @MarcoGorelli (cc @rich-iannone), this PR adds a DataFrame.style property, which returns a
great_tables.GT
object. This allows a polars DataFrame to quickly be customized for presentation.The 3 big pieces Great Tables focuses on are structure, formatting, and style--which are emphasized in the Polars user guide. Polars expressions ended up really shaping the Great Tables API, so we hope a lot of the approach (e.g. using polars selectors to specify columns) will feel natural to folks!
Happy to make any changes, do anything useful :)
Demo
Here is the full example added to the user guide: