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

let indicator allow strings #2284

Merged
merged 6 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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/abstractdataframe/join.jl
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ end

function _join(df1::AbstractDataFrame, df2::AbstractDataFrame;
on::Union{<:OnType, AbstractVector}, kind::Symbol, makeunique::Bool,
indicator::Union{Nothing, Symbol},
indicator::Union{Nothing, Symbol, <:AbstractString},
bkamins marked this conversation as resolved.
Show resolved Hide resolved
validate::Union{Pair{Bool, Bool}, Tuple{Bool, Bool}})
_check_consistency(df1)
_check_consistency(df2)
Expand Down Expand Up @@ -489,7 +489,7 @@ the result. A left join includes all rows from `df1`.
if `true`, duplicate names will be suffixed with `_i`
(`i` starting at 1 for the first duplicate).
- `indicator` : Default: `nothing`. If a `Symbol`, adds categorical indicator
column named `Symbol` for whether a row appeared in only `df1` (`"left_only"`),
column with the given name for whether a row appeared in only `df1` (`"left_only"`),
bkamins marked this conversation as resolved.
Show resolved Hide resolved
only `df2` (`"right_only"`) or in both (`"both"`). If `Symbol` is already in use,
the column name will be modified if `makeunique=true`.
- `validate` : whether to check that columns passed as the `on` argument
Expand Down Expand Up @@ -566,7 +566,7 @@ julia> leftjoin(name, job2, on = [:ID => :identifier])
"""
leftjoin(df1::AbstractDataFrame, df2::AbstractDataFrame;
on::Union{<:OnType, AbstractVector} = Symbol[],
makeunique::Bool=false, indicator::Union{Nothing, Symbol} = nothing,
makeunique::Bool=false, indicator::Union{Nothing, Symbol, <:AbstractString} = nothing,
validate::Union{Pair{Bool, Bool}, Tuple{Bool, Bool}}=(false, false)) =
_join(df1, df2, on=on, kind=:left, makeunique=makeunique, indicator=indicator,
validate=validate)
Expand All @@ -592,7 +592,7 @@ the result. A right join includes all rows from `df2`.
if `true`, duplicate names will be suffixed with `_i`
(`i` starting at 1 for the first duplicate).
- `indicator` : Default: `nothing`. If a `Symbol`, adds categorical indicator
column named `Symbol` for whether a row appeared in only `df1` (`"left_only"`),
column with the given name for whether a row appeared in only `df1` (`"left_only"`),
only `df2` (`"right_only"`) or in both (`"both"`). If `Symbol` is already in use,
the column name will be modified if `makeunique=true`.
- `validate` : whether to check that columns passed as the `on` argument
Expand Down Expand Up @@ -669,7 +669,7 @@ julia> rightjoin(name, job2, on = [:ID => :identifier])
"""
rightjoin(df1::AbstractDataFrame, df2::AbstractDataFrame;
on::Union{<:OnType, AbstractVector} = Symbol[],
makeunique::Bool=false, indicator::Union{Nothing, Symbol} = nothing,
makeunique::Bool=false, indicator::Union{Nothing, Symbol, <:AbstractString} = nothing,
validate::Union{Pair{Bool, Bool}, Tuple{Bool, Bool}}=(false, false)) =
_join(df1, df2, on=on, kind=:right, makeunique=makeunique, indicator=indicator,
validate=validate)
Expand Down Expand Up @@ -700,7 +700,7 @@ of the passed data frames.
if `true`, duplicate names will be suffixed with `_i`
(`i` starting at 1 for the first duplicate).
- `indicator` : Default: `nothing`. If a `Symbol`, adds categorical indicator
column named `Symbol` for whether a row appeared in only `df1` (`"left_only"`),
column with the given name for whether a row appeared in only `df1` (`"left_only"`),
only `df2` (`"right_only"`) or in both (`"both"`). If `Symbol` is already in use,
the column name will be modified if `makeunique=true`.
This argument is only supported when joining exactly two data frames.
Expand Down Expand Up @@ -786,7 +786,7 @@ julia> outerjoin(name, job2, on = [:ID => :identifier])
"""
outerjoin(df1::AbstractDataFrame, df2::AbstractDataFrame;
on::Union{<:OnType, AbstractVector} = Symbol[],
makeunique::Bool=false, indicator::Union{Nothing, Symbol} = nothing,
makeunique::Bool=false, indicator::Union{Nothing, Symbol, <:AbstractString} = nothing,
validate::Union{Pair{Bool, Bool}, Tuple{Bool, Bool}}=(false, false)) =
_join(df1, df2, on=on, kind=:outer, makeunique=makeunique, indicator=indicator,
validate=validate)
Expand Down Expand Up @@ -818,7 +818,7 @@ match with the keys in `df2`.
if `true`, duplicate names will be suffixed with `_i`
(`i` starting at 1 for the first duplicate).
- `indicator` : Default: `nothing`. If a `Symbol`, adds categorical indicator
column named `Symbol` for whether a row appeared in only `df1` (`"left_only"`),
column with the given name for whether a row appeared in only `df1` (`"left_only"`),
only `df2` (`"right_only"`) or in both (`"both"`). If `Symbol` is already in use,
the column name will be modified if `makeunique=true`.
- `validate` : whether to check that columns passed as the `on` argument
Expand Down
3 changes: 3 additions & 0 deletions test/join.jl
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,10 @@ end
pre_join_name = copy(name)
pre_join_job = copy(job)
@test outerjoin(name, job, on = :ID, indicator=:_merge,
makeunique=true) ≅
outerjoin(name, job, on = :ID, indicator="_merge",
makeunique=true) ≅ outer_indicator

@test name ≅ pre_join_name
@test job ≅ pre_join_job

Expand Down