@@ -974,7 +974,7 @@ A convenient shortcut for `ds[byrow(ds, type, cols; ...), :]`.
974974
975975`type` can be any function supported by `byrow` which returns a Vector{Bool} or BitVector.
976976
977- See [`byrow`](@ref), [`filter!`](@ref)
977+ See [`byrow`](@ref), [`filter!`](@ref), [`delete!`](@ref), [`delete`](@ref)
978978
979979# Examples
980980
@@ -1056,10 +1056,110 @@ It is a convenient shortcut for `deleteat![ds, .!byrow(ds, type, cols; ...)]`.
10561056
10571057Refer to [`filter`](@ref) for exmaples.
10581058
1059- See [`byrow`](@ref), [`filter`](@ref)
1059+ See [`byrow`](@ref), [`filter`](@ref), [`delete!`](@ref), [`delete`](@ref)
10601060"""
10611061Base. filter! (ds:: Dataset , cols:: Union{ColumnIndex, MultiColumnIndex} ; type = all, kwargs... ) = deleteat! (ds, .! byrow (ds, type, cols; kwargs... ))
10621062
1063+ # filter out `true`s
1064+ """
1065+ delete(ds::AbstractDataset, cols; [type = all,...])
1066+
1067+ A convenient shortcut for `ds[.!byrow(ds, type, cols; ...), :]`.
1068+
1069+ `type` can be any function supported by `byrow` which returns a Vector{Bool} or BitVector.
1070+
1071+ Compare to [`deleteat!`](@ref)
1072+
1073+ See [`delete!`](@ref), [`byrow`](@ref), [`filter!`](@ref), [`filter`](@ref)
1074+
1075+ # Examples
1076+
1077+ ```jldoctest
1078+ julia> ds = Dataset(x = [1,2,3,4,5], y = [1.5,2.3,-1,0,2.0], z = Bool[1,0,1,0,1])
1079+ 5×3 Dataset
1080+ Row │ x y z
1081+ │ identity identity identity
1082+ │ Int64? Float64? Bool?
1083+ ─────┼──────────────────────────────
1084+ 1 │ 1 1.5 true
1085+ 2 │ 2 2.3 false
1086+ 3 │ 3 -1.0 true
1087+ 4 │ 4 0.0 false
1088+ 5 │ 5 2.0 true
1089+
1090+ julia> delete(ds, :z)
1091+ 2×3 Dataset
1092+ Row │ x y z
1093+ │ identity identity identity
1094+ │ Int64? Float64? Bool?
1095+ ─────┼──────────────────────────────
1096+ 1 │ 2 2.3 false
1097+ 2 │ 4 0.0 false
1098+
1099+ julia> delete(ds, 1:2, by = [iseven, >(2.0)])
1100+ 4×3 Dataset
1101+ Row │ x y z
1102+ │ identity identity identity
1103+ │ Int64? Float64? Bool?
1104+ ─────┼──────────────────────────────
1105+ 1 │ 1 1.5 true
1106+ 2 │ 3 -1.0 true
1107+ 3 │ 4 0.0 false
1108+ 4 │ 5 2.0 true
1109+
1110+ julia> delete(ds, 1:2, type = any, by = [iseven, >(2.0)])
1111+ 3×3 Dataset
1112+ Row │ x y z
1113+ │ identity identity identity
1114+ │ Int64? Float64? Bool?
1115+ ─────┼──────────────────────────────
1116+ 1 │ 1 1.5 true
1117+ 2 │ 3 -1.0 true
1118+ 3 │ 5 2.0 true
1119+
1120+ julia> delete(ds, 1:3, type = issorted, rev = true)
1121+ 3×3 Dataset
1122+ Row │ x y z
1123+ │ identity identity identity
1124+ │ Int64? Float64? Bool?
1125+ ─────┼──────────────────────────────
1126+ 1 │ 1 1.5 true
1127+ 2 │ 2 2.3 false
1128+ 3 │ 3 -1.0 true
1129+
1130+ julia> delete(ds, 2:3, type = isless, with = :x)
1131+ 2×3 Dataset
1132+ Row │ x y z
1133+ │ identity identity identity
1134+ │ Int64? Float64? Bool?
1135+ ─────┼──────────────────────────────
1136+ 1 │ 1 1.5 true
1137+ 2 │ 2 2.3 false
1138+ ```
1139+ """
1140+ function delete (ds:: AbstractDataset , cols:: Union{ColumnIndex, MultiColumnIndex} ; view = false , type= all, kwargs... )
1141+ if view
1142+ Base. view (ds, .! byrow (ds, type, cols; kwargs... ), :)
1143+ else
1144+ ds[.! byrow (ds, type, cols; kwargs... ), :]
1145+ end
1146+ end
1147+ """
1148+ delete!(ds::AbstractDataset, cols; [type = all, ...])
1149+
1150+ Variant of `delete` which replaces the passed data set with the filtered one.
1151+
1152+ It is a convenient shortcut for `deleteat![ds, byrow(ds, type, cols; ...)]`.
1153+
1154+ `type` can be any function supported by `byrow` which returns a Vector{Bool} or BitVector.
1155+
1156+ Compare to [`deleteat!`](@ref)
1157+
1158+ Refer to [`delete`](@ref) for exmaples.
1159+
1160+ See [`delete`](@ref), [`byrow`](@ref), [`filter`](@ref), [`filter!`](@ref)
1161+ """
1162+ Base. delete! (ds:: Dataset , cols:: Union{ColumnIndex, MultiColumnIndex} ; type = all, kwargs... ) = deleteat! (ds, byrow (ds, type, cols; kwargs... ))
10631163
10641164"""
10651165 mapcols(ds::AbstractDataset, f, cols)
0 commit comments