Skip to content

Commit b23dcf1

Browse files
committed
support byrow with tuples in filter/!, delete/!
1 parent 6ec8419 commit b23dcf1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/dataset/other.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ julia> filter(ds, 2:3, type = isless, with = :x)
10381038
3 │ 5 2.0 true
10391039
```
10401040
"""
1041-
function Base.filter(ds::AbstractDataset, cols::Union{Vector{T}, ColumnIndex, MultiColumnIndex}; view = false, type= all, kwargs...) where T <: Union{<:Integer, Symbol, AbstractString}
1041+
function Base.filter(ds::AbstractDataset, cols::Union{NTuple{N, ColumnIndex}, Vector{T}, ColumnIndex, MultiColumnIndex}; view = false, type= all, kwargs...) where N where T <: Union{<:Integer, Symbol, AbstractString}
10421042
if view
10431043
Base.view(ds, byrow(ds, type, cols; kwargs...), :)
10441044
else
@@ -1058,9 +1058,11 @@ Refer to [`filter`](@ref) for exmaples.
10581058
10591059
See [`byrow`](@ref), [`filter`](@ref), [`delete!`](@ref), [`delete`](@ref)
10601060
"""
1061-
_filter!(ds::Dataset, cols::Union{AbstractVector{T}, ColumnIndex, MultiColumnIndex}; type = all, kwargs...) where T <: Union{<:Integer, Symbol, AbstractString} = deleteat!(ds, .!byrow(ds, type, cols; kwargs...))
1061+
_filter!(ds::Dataset, cols::Union{NTuple{N, ColumnIndex}, AbstractVector{T}, ColumnIndex, MultiColumnIndex}; type = all, kwargs...) where N where T <: Union{<:Integer, Symbol, AbstractString} = deleteat!(ds, .!byrow(ds, type, cols; kwargs...))
10621062
Base.filter!(ds::Dataset, cols::AbstractVector; type = all, kwargs...) = _filter!(ds, cols; type = type, kwargs...)
10631063
Base.filter!(ds::Dataset, cols::Union{ColumnIndex, MultiColumnIndex}; type = all, kwargs...) = _filter!(ds, cols; type = type, kwargs...)
1064+
Base.filter!(ds::Dataset, cols::NTuple{N, ColumnIndex}; kwargs...) where N = _filter!(ds, cols; kwargs...)
1065+
10641066

10651067
# filter out `true`s
10661068
"""
@@ -1139,7 +1141,7 @@ julia> delete(ds, 2:3, type = isless, with = :x)
11391141
2 │ 2 2.3 false
11401142
```
11411143
"""
1142-
function delete(ds::AbstractDataset, cols::Union{ColumnIndex, MultiColumnIndex}; view = false, type= all, kwargs...)
1144+
function delete(ds::AbstractDataset, cols::Union{NTuple{N, ColumnIndex}, ColumnIndex, MultiColumnIndex}; view = false, type= all, kwargs...) where N
11431145
if view
11441146
Base.view(ds, .!byrow(ds, type, cols; kwargs...), :)
11451147
else
@@ -1161,7 +1163,7 @@ Refer to [`delete`](@ref) for exmaples.
11611163
11621164
See [`delete`](@ref), [`byrow`](@ref), [`filter`](@ref), [`filter!`](@ref)
11631165
"""
1164-
Base.delete!(ds::Dataset, cols::Union{ColumnIndex, MultiColumnIndex}; type = all, kwargs...) = deleteat!(ds, byrow(ds, type, cols; kwargs...))
1166+
Base.delete!(ds::Dataset, cols::Union{NTuple{N, ColumnIndex}, ColumnIndex, MultiColumnIndex}; type = all, kwargs...) where N = deleteat!(ds, byrow(ds, type, cols; kwargs...))
11651167

11661168
"""
11671169
mapcols(ds::AbstractDataset, f, cols)

0 commit comments

Comments
 (0)