Skip to content
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 across #452

Merged
merged 27 commits into from Oct 12, 2022
Merged

Feat across #452

merged 27 commits into from Oct 12, 2022

Conversation

machow
Copy link
Owner

@machow machow commented Sep 28, 2022

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()

@machow machow marked this pull request as ready for review October 3, 2022 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant