-
Notifications
You must be signed in to change notification settings - Fork 73
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #566 +/- ##
==========================================
+ Coverage 90.67% 90.70% +0.02%
==========================================
Files 46 46
Lines 5381 5409 +28
==========================================
+ Hits 4879 4906 +27
- Misses 502 503 +1 ☔ 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.
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.