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

Replace deepcopy() with transform(; ungroup = false), which is faster. #29

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/TidierData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ macro select(df, exprs...)
df_expr = quote
if $any_found_n || $any_found_row_number
if $(esc(df)) isa GroupedDataFrame
local df_copy = deepcopy($(esc(df)))
local df_copy = transform($(esc(df)); ungroup = false)
else
local df_copy = copy($(esc(df)))
end
Expand Down Expand Up @@ -129,7 +129,7 @@ macro transmute(df, exprs...)
df_expr = quote
if $any_found_n || $any_found_row_number
if $(esc(df)) isa GroupedDataFrame
local df_copy = deepcopy($(esc(df)))
local df_copy = transform($(esc(df)); ungroup = false)
else
local df_copy = copy($(esc(df)))
end
Expand Down Expand Up @@ -187,7 +187,7 @@ macro rename(df, exprs...)
df_expr = quote
if $any_found_n || $any_found_row_number
if $(esc(df)) isa GroupedDataFrame
local df_copy = deepcopy($(esc(df)))
local df_copy = transform($(esc(df)); ungroup = false)
else
local df_copy = copy($(esc(df)))
end
Expand Down Expand Up @@ -245,7 +245,7 @@ macro mutate(df, exprs...)
df_expr = quote
if $any_found_n || $any_found_row_number
if $(esc(df)) isa GroupedDataFrame
local df_copy = deepcopy($(esc(df)))
local df_copy = transform($(esc(df)); ungroup = false)
else
local df_copy = copy($(esc(df)))
end
Expand Down Expand Up @@ -303,7 +303,7 @@ macro summarize(df, exprs...)
df_expr = quote
if $any_found_n || $any_found_row_number
if $(esc(df)) isa GroupedDataFrame
local df_copy = deepcopy($(esc(df)))
local df_copy = transform($(esc(df)); ungroup = false)
else
local df_copy = copy($(esc(df)))
end
Expand Down Expand Up @@ -374,7 +374,7 @@ macro filter(df, exprs...)
df_expr = quote
if $any_found_n || $any_found_row_number
if $(esc(df)) isa GroupedDataFrame
local df_copy = deepcopy($(esc(df)))
local df_copy = transform($(esc(df)); ungroup = false)
else
local df_copy = copy($(esc(df)))
end
Expand Down Expand Up @@ -436,7 +436,7 @@ macro group_by(df, exprs...)

if $any_found_n || $any_found_row_number || any_expressions
if $(esc(df)) isa GroupedDataFrame
local df_copy = deepcopy($(esc(df)))
local df_copy = transform($(esc(df)); ungroup = false)
else
local df_copy = copy($(esc(df)))
end
Expand Down Expand Up @@ -566,7 +566,7 @@ macro distinct(df, exprs...)

# `@distinct()` uses a different pattern from the other macros
# because if the original DataFrame is grouped, it must be ungrouped
# and then regrouped, so there's no need to make a deepcopy.
# and then regrouped, so there's no need to make a copy up front.
# This is because `unique()` does not work on GroupDataFrames.
local df_copy = DataFrame($(esc(df)))
if $any_found_n
Expand Down