This PR implements the across() bridge function, across all verbs except arrange() (for now). It also refactors sql verb implementations, cleaning up and consolidating their logic.
Note that this PR introduces context variables (similar to dplyr). This is because across() needs access to the original sql LazyTbl in order to translate its functions into their dialect specific implementations. Currently, two context variables are set -- one for the LazyTbl, and one to indicate whether or not to use a windowed or agg translation. This should be cleaned u up in the future.
All-in-all, the following changes were made:
feat: add across(), which can be used inside verbs to apply one operation to multiple columns.
feat: count() and add_count() support the name argument.
feat: the new symbolic "formula" object, Fx, now exposed as a top level import.
feat: implement grouped distinct for both pandas and sql.
feat(tidyselect)!: a lambda can no longer be used to create a tidyselection specifier. Instead we match dplyr's behavior:
old: lambda _: _.startswith("abc") was equivalent to _.startswith("abc")
Now, when select() is given a callable function, it passes each column of data to it, and expects back a boolean.
new: select(cars, lambda ser: ser.dtype == "int")
.
fix: add_count() now correctly handles named arguments, is tested for most cases count() is tested on.
fix(sql)!: calling arrange() twice now resets the order_by variables set by the first call (matching dbplyr behavior).
.
internal:
improve group handling -- the _make_groupby_safe() function ensures group_keys is false.
consolidate much of the mutation logic into a single function _mutate_cols. This is used in many verbs: mutate(), transmute(), and distinct(), and indirectly in group_by()
This PR implements the
across()
bridge function, across all verbs exceptarrange()
(for now). It also refactors sql verb implementations, cleaning up and consolidating their logic.Note that this PR introduces context variables (similar to dplyr). This is because
across()
needs access to the original sqlLazyTbl
in order to translate its functions into their dialect specific implementations. Currently, two context variables are set -- one for the LazyTbl, and one to indicate whether or not to use a windowed or agg translation. This should be cleaned u up in the future.All-in-all, the following changes were made:
across()
, which can be used inside verbs to apply one operation to multiple columns.count()
andadd_count()
support thename
argument.Fx
, now exposed as a top level import.lambda _: _.startswith("abc")
was equivalent to_.startswith("abc")
select()
is given a callable function, it passes each column of data to it, and expects back a boolean.select(cars, lambda ser: ser.dtype == "int")
.
add_count()
now correctly handles named arguments, is tested for most casescount()
is tested on.arrange()
twice now resets the order_by variables set by the first call (matching dbplyr behavior)..
_make_groupby_safe()
function ensures group_keys is false._mutate_cols
. This is used in many verbs:mutate()
,transmute()
, anddistinct()
, and indirectly ingroup_by()