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

Improve performance of by() using NamedTuples #1520

Merged
merged 19 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion docs/src/lib/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ Pages = ["functions.md"]
aggregate
by
colwise
combine
groupby
join
map
melt
stack
unstack
Expand All @@ -27,7 +29,6 @@ meltdf

```@docs
allowmissing!
combine
completecases
describe
disallowmissing!
Expand Down
4 changes: 2 additions & 2 deletions src/DataFrames.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module DataFrames

using Reexport, StatsBase, SortingAlgorithms, Compat, Statistics, Unicode, Printf
@reexport using CategoricalArrays, Missings
using Base.Sort, Base.Order
using Base.Sort, Base.Order, Base.Iterators

##############################################################################
##
Expand Down Expand Up @@ -73,8 +73,8 @@ include("other/index.jl")
include("abstractdataframe/abstractdataframe.jl")
include("dataframe/dataframe.jl")
include("subdataframe/subdataframe.jl")
include("groupeddataframe/grouping.jl")
include("dataframerow/dataframerow.jl")
include("groupeddataframe/grouping.jl")
include("dataframerow/utils.jl")

include("abstractdataframe/iteration.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/dataframe/dataframe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ end

# definition required to avoid hcat! ambiguity
function hcat!(df1::DataFrame, df2::DataFrame; makeunique::Bool=false)
invoke(hcat!, Tuple{DataFrame, AbstractDataFrame}, df1, df2, makeunique=makeunique)
invoke(hcat!, Tuple{DataFrame, AbstractDataFrame}, df1, df2, makeunique=makeunique)::DataFrame
end

hcat!(df::DataFrame, x::AbstractVector; makeunique::Bool=false) =
Expand Down
8 changes: 6 additions & 2 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1633,8 +1633,9 @@ function Base.append!(df1::DataFrame, df2::SubDataFrame)
return df1
end

function groupby(df::SubDataFrame, cols::Vector;
function groupby(df::SubDataFrame, cols::AbstractVector;
sort::Bool = false, skipmissing::Bool = false)
intcols = index(df)[cols]
sdf = SubDataFrame(parent(df)[cols], rows(df))
df_groups = group_rows(sdf, skipmissing)
# sort the groups
Expand All @@ -1643,7 +1644,7 @@ function groupby(df::SubDataFrame, cols::Vector;
permute!(df_groups.starts, group_perm)
Base.permute!!(df_groups.stops, group_perm)
end
GroupedDataFrame(df, cols, df_groups.rperm,
GroupedDataFrame(df, intcols, df_groups.rperm,
df_groups.starts, df_groups.stops)
end

Expand Down Expand Up @@ -1740,3 +1741,6 @@ function hashrows(df::SubDataFrame, skipmissing::Bool)
end

# TODO: END: Deprecations to be removed after getindex deprecation period finishes

import Base: map
@deprecate map(f::Function, sdf::SubDataFrame) f(sdf)
Loading