-
Notifications
You must be signed in to change notification settings - Fork 75
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
Support mask=
argument in LocBody
#566
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #566 +/- ##
==========================================
+ Coverage 90.67% 90.73% +0.06%
==========================================
Files 46 46
Lines 5381 5416 +35
==========================================
+ Hits 4879 4914 +35
Misses 502 502 ☔ View full report in Codecov by Sentry. |
mask=
argument in GT.tab_style()
mask=
argument in LocBody()
mask=
argument in LocBody()
mask=
argument in LocBody
great_tables/_locations.py
Outdated
cols_excl = [*(stub_var if excl_stub else []), *(group_var if excl_group else [])] | ||
|
||
frame: PlDataFrame = data._tbl_data | ||
df = frame.select(expr) |
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.
What if the rules for the mask were as follows?:
- the mask expressions should--when run by
frame.select(mask_expr)
--return a DataFrame that:- columns: has the same or fewer columns (names must match original frame, but could be in a different order).
- rows: has the same number of rows
- after running the expression, we validate this right away
- the mask is assumed to be in the original row order
- in this case we can capture the column name and row number of each cell (e.g. with
enumerate(mask_result.iter_rows())
).
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.
Thanks for summarizing the rules.
It seems that for the last part, we only need a single loop to gather all the information required by CellPos
.
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.
How about this version?
For prototyping, use assert
for validation, which can later be replaced with raise ValueError()
.
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.
I've replaced assert
with raise ValueError()
and added more test cases.
@jrycw this is looking really good! Anything else needed for this PR? I'm happy to help with any pieces! |
@machow One thing I’m unsure about is the naming of the function. Specifically, I’m not clear on what the |
I can help!
this is admittedly a bit of a holdover from the R package (which also has the |
@rich-iannone Thanks for the explanation! I agree that |
From a quick glance it's looking really nice -- if it's ready for review I'm happy to take a closer look! |
The PR should be ready for review; please proceed. |
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.
This is looking really great--thanks for taking the time to implement this! I left several small suggestions for some error wording, and tweaks. Always happy to pick things up from here if useful. Thanks again for all the work you put into this!
@machow, I truly appreciate your review—all your suggestions are spot on! Also, it’s great to see all green checks again. |
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.
This looks really great, thanks! @rich-iannone do you want to merge?
Related Issue: #389.
Hello team,
This is a rough idea for supporting the passing of
Polars
expressions to themask=
argument ofLobBody
.The procedures are outlined as follows:
stub
andgroup
columns if necessary.df.select()
to process thePolars
expression and obtain a boolean-like matrix.True
.This idea is preliminary but should provide a foundation for further discussions.