Skip to content

Commit

Permalink
Rewrite @slice() to support interpolation and functions, adds `wher…
Browse files Browse the repository at this point in the history
…e()` and `is_number()`
  • Loading branch information
Karandeep Singh committed Dec 21, 2023
1 parent 9c42273 commit f71893d
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

0 comments on commit f71893d

Please sign in to comment.