Skip to content

Commit

Permalink
Merge pull request #75 from TidierOrg/rewrite-slice
Browse files Browse the repository at this point in the history
Rewrite `@slice()` to support interpolation and functions, adds `wher…
  • Loading branch information
Karandeep Singh committed Dec 21, 2023
2 parents 9c42273 + f71893d commit de86edf
Show file tree
Hide file tree
Showing 10 changed files with 364 additions and 254 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# TidierData.jl updates

## v0.14.2 - 2023-12-21
- `@slice()` now supports interpolation and user-defined functions
- Adds `where()`
- Adds `is_number()`

## v0.14.1 - 2023-12-19
- `@separate()` now supports regular expressions
- Adds `@separate_rows()`
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TidierData"
uuid = "fe2206b3-d496-4ee9-a338-6a095c4ece80"
authors = ["Karandeep Singh"]
version = "0.14.1"
version = "0.14.2"

[deps]
Chain = "8be319e6-bccf-4806-a6f7-6fae938471bc"
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,15 @@ TidierData.jl currently supports the following top-level macros:
TidierData.jl also supports the following helper functions:

- `across()`
- `where()`
- `desc()`
- `if_else()` and `case_when()`
- `n()` and `row_number()`
- `ntile()`
- `lag()` and `lead()`
- `everything()`, `starts_with()`, `ends_with()`, `matches()`, and `contains()`
- `as_float()`, `as_integer()`, and `as_string()`
- `is_float()`, `is_integer()`, and `is_string()`
- `is_number()`, `is_float()`, `is_integer()`, and `is_string()`
- `missing_if()` and `replace_missing()`

See the documentation [Home](https://tidierorg.github.io/TidierData.jl/latest/) page for a guide on how to get started, or the [Reference](https://tidierorg.github.io/TidierData.jl/latest/reference/) page for a detailed guide to each of the macros and functions.
Expand Down
3 changes: 2 additions & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,15 @@ TidierData.jl also supports the following helper functions:
```@raw html
!!! example "Helper functions:"
- `across()`
- `where()`
- `desc()`
- `if_else()` and `case_when()`
- `n()` and `row_number()`
- `ntile()`
- `lag()` and `lead()`
- `everything()`, `starts_with()`, `ends_with()`, `matches()`, and `contains()`
- `as_float()`, `as_integer()`, and `as_string()`
- `is_float()`, `is_integer()`, and `is_string()`
- `is_number()`, `is_float()`, `is_integer()`, and `is_string()`
- `missing_if()` and `replace_missing()`
```

Expand Down
7 changes: 4 additions & 3 deletions src/TidierData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ using Reexport
@reexport using ShiftedArrays: lag, lead

export TidierData_set, across, desc, n, row_number, everything, starts_with, ends_with, matches, if_else, case_when, ntile,
as_float, as_integer, as_string, is_float, is_integer, is_string, missing_if, replace_missing, @select, @transmute, @rename, @mutate, @summarize, @summarise, @filter,
as_float, as_integer, as_string, is_number, is_float, is_integer, is_string, missing_if, replace_missing, where,
@select, @transmute, @rename, @mutate, @summarize, @summarise, @filter,
@group_by, @ungroup, @slice, @arrange, @distinct, @pull, @left_join, @right_join, @inner_join, @full_join, @anti_join, @semi_join,
@pivot_wider, @pivot_longer, @bind_rows, @bind_cols, @clean_names, @count, @tally, @drop_missing, @glimpse, @separate,
@unite, @summary, @fill_missing, @slice_sample, @slice_min, @slice_max, @slice_head, @slice_tail, @rename_with, @separate_rows
Expand All @@ -30,7 +31,7 @@ const not_vectorized = Ref{Vector{Symbol}}([:esc, :Ref, :Set, :Cols, :collect, :

# The global do-not-escape "list"
# `in`, `∈`, and `∉` should be vectorized in auto-vec but not escaped
const not_escaped = Ref{Vector{Symbol}}([:esc, :in, :, :, :Ref, :Set, :Cols, :collect, :(:), :, :(=>), :across, :desc, :mean, :std, :var, :median, :first, :last, :minimum, :maximum, :sum, :length, :skipmissing, :quantile, :passmissing, :startswith, :contains, :endswith])
const not_escaped = Ref{Vector{Symbol}}([:where, :esc, :in, :, :, :Ref, :Set, :Cols, :collect, :(:), :, :(=>), :across, :desc, :mean, :std, :var, :median, :first, :last, :minimum, :maximum, :sum, :length, :skipmissing, :quantile, :passmissing, :startswith, :contains, :endswith])

# Includes
include("docstrings.jl")
Expand Down Expand Up @@ -301,7 +302,7 @@ end
$docstring_summarize
"""
macro summarize(df, exprs...)
interpolated_exprs = parse_interpolation.(exprs; summarize = true)
interpolated_exprs = parse_interpolation.(exprs; from_summarize = true)

tidy_exprs = [i[1] for i in interpolated_exprs]
any_found_n = any([i[2] for i in interpolated_exprs])
Expand Down
Loading

2 comments on commit de86edf

@kdpsingh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/97523

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.14.2 -m "<description of version>" de86edf152e3d0f64f61f26b4e2e17d98c17e4b3
git push origin v0.14.2

Please sign in to comment.