Skip to content

Commit 9a035d1

Browse files
authored
Merge pull request #107 from TidierOrg/v16-0
V0-16-0
2 parents 8f8cfd0 + 6d4922c commit 9a035d1

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# TidierData.jl updates
22

3+
## v0.16.0 - 2024-06-07
4+
- `unique()`, `mad()`, and `iqr()` are no longer auto-vectorized
5+
- Bugfix: `@ungroup()` now preserves row-ordering (and is faster)
6+
- Bugfix: `slice_sample()` now throws an error if no `n` or `prop` keyword argument is provided
7+
- Bump minimum Julia version to 1.9
8+
39
## v0.15.2 - 2024-04-19
410
- Update Chain.jl dependency version
511

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TidierData"
22
uuid = "fe2206b3-d496-4ee9-a338-6a095c4ece80"
33
authors = ["Karandeep Singh"]
4-
version = "0.15.2"
4+
version = "0.16.0"
55

66
[deps]
77
Chain = "8be319e6-bccf-4806-a6f7-6fae938471bc"
@@ -22,7 +22,7 @@ Reexport = "0.2, 1"
2222
ShiftedArrays = "2"
2323
Statistics = "1.6"
2424
StatsBase = "0.34, 1"
25-
julia = "1.6"
25+
julia = "1.9"
2626

2727
[extras]
2828
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

docs/examples/UserGuide/slice.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ end
6464
# ## Sample 5 random rows in the data frame
6565

6666
@chain df begin
67-
@slice_sample(5)
67+
@slice_sample(n = 5)
6868
end
6969

7070
# ## Slice the min

src/TidierData.jl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const code = Ref{Bool}(false) # output DataFrames.jl code?
2828
const log = Ref{Bool}(false) # output tidylog output? (not yet implemented)
2929

3030
# The global do-not-vectorize "list"
31-
const not_vectorized = Ref{Vector{Symbol}}([:getindex, :rand, :esc, :Ref, :Set, :Cols, :collect, :(:), :, :lag, :lead, :ntile, :repeat, :across, :desc, :mean, :std, :var, :median, :first, :last, :minimum, :maximum, :sum, :length, :skipmissing, :quantile, :passmissing, :cumsum, :cumprod, :accumulate, :is_float, :is_integer, :is_string, :cat_rev, :cat_relevel, :cat_infreq, :cat_lump, :cat_reorder, :cat_collapse, :cat_lump_min, :cat_lump_prop, :categorical, :as_categorical, :is_categorical])
31+
const not_vectorized = Ref{Vector{Symbol}}([:getindex, :rand, :esc, :Ref, :Set, :Cols, :collect, :(:), :, :lag, :lead, :ntile, :repeat, :across, :desc, :mean, :std, :var, :median, :mad, :first, :last, :minimum, :maximum, :sum, :length, :skipmissing, :quantile, :passmissing, :cumsum, :cumprod, :accumulate, :is_float, :is_integer, :is_string, :cat_rev, :cat_relevel, :cat_infreq, :cat_lump, :cat_reorder, :cat_collapse, :cat_lump_min, :cat_lump_prop, :categorical, :as_categorical, :is_categorical, :unique, :iqr])
3232

3333
# The global do-not-escape "list"
3434
# `in`, `∈`, and `∉` should be vectorized in auto-vec but not escaped
@@ -494,7 +494,17 @@ end
494494
$docstring_ungroup
495495
"""
496496
macro ungroup(df)
497-
:(DataFrame($(esc(df))))
497+
df_expr = quote
498+
if $(esc(df)) isa GroupedDataFrame
499+
transform($(esc(df)); ungroup = true)
500+
else
501+
copy($(esc(df)))
502+
end
503+
end
504+
if code[]
505+
@info MacroTools.prettify(df_expr)
506+
end
507+
return df_expr
498508
end
499509

500510
"""
@@ -542,7 +552,7 @@ macro distinct(df, exprs...)
542552
# because if the original DataFrame is grouped, it must be ungrouped
543553
# and then regrouped, so there's no need to make a copy up front.
544554
# This is because `unique()` does not work on GroupDataFrames.
545-
local df_copy = DataFrame($(esc(df)))
555+
local df_copy = transform($(esc(df)); ungroup = true)
546556
if $any_found_n
547557
transform!(df_copy, nrow => :TidierData_n)
548558
end

src/slice.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ macro slice_sample(df, exprs...)
6464
as_integer(floor(n() * $expr_dict[:prop]));
6565
replace=$replace))
6666
else
67-
@slice($(esc(df)), sample(1:n(), 1; replace=$replace))
67+
throw("Please provide either an `n` or a `prop` value as a keyword argument.")
6868
end
6969
end
7070

0 commit comments

Comments
 (0)