You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A convenient shortcut for ds[byrow(ds, type, cols; ...), :]. `type` can be any function supported by `byrow` which returns a Vector{Bool} or BitVector.
1061
+
A convenient shortcut for `ds[byrow(ds, type, cols; ...), :]`.
1062
1062
1063
-
See [`byrow`](@ref)
1063
+
`type` can be any function supported by `byrow` which returns a Vector{Bool} or BitVector.
1064
+
1065
+
See [`byrow`](@ref), [`filter!`](@ref)
1066
+
1067
+
# Examples
1068
+
1069
+
```jldoctest
1070
+
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])
1071
+
5×3 Dataset
1072
+
Row │ x y z
1073
+
│ identity identity identity
1074
+
│ Int64? Float64? Bool?
1075
+
─────┼──────────────────────────────
1076
+
1 │ 1 1.5 true
1077
+
2 │ 2 2.3 false
1078
+
3 │ 3 -1.0 true
1079
+
4 │ 4 0.0 false
1080
+
5 │ 5 2.0 true
1081
+
1082
+
julia> filter(ds, :z)
1083
+
3×3 Dataset
1084
+
Row │ x y z
1085
+
│ identity identity identity
1086
+
│ Int64? Float64? Bool?
1087
+
─────┼──────────────────────────────
1088
+
1 │ 1 1.5 true
1089
+
2 │ 3 -1.0 true
1090
+
3 │ 5 2.0 true
1091
+
1092
+
julia> filter(ds, 1:2, by = [iseven, >(2.0)])
1093
+
1×3 Dataset
1094
+
Row │ x y z
1095
+
│ identity identity identity
1096
+
│ Int64? Float64? Bool?
1097
+
─────┼──────────────────────────────
1098
+
1 │ 2 2.3 false
1099
+
1100
+
julia> filter(ds, 1:2, type = any, by = [iseven, >(2.0)])
1101
+
2×3 Dataset
1102
+
Row │ x y z
1103
+
│ identity identity identity
1104
+
│ Int64? Float64? Bool?
1105
+
─────┼──────────────────────────────
1106
+
1 │ 2 2.3 false
1107
+
2 │ 4 0.0 false
1108
+
1109
+
julia> filter(ds, 1:3, type = issorted, rev = true)
1110
+
2×3 Dataset
1111
+
Row │ x y z
1112
+
│ identity identity identity
1113
+
│ Int64? Float64? Bool?
1114
+
─────┼──────────────────────────────
1115
+
1 │ 4 0.0 false
1116
+
2 │ 5 2.0 true
1117
+
1118
+
julia> filter(ds, 2:3, type = isless, with = :x)
1119
+
3×3 Dataset
1120
+
Row │ x y z
1121
+
│ identity identity identity
1122
+
│ Int64? Float64? Bool?
1123
+
─────┼──────────────────────────────
1124
+
1 │ 3 -1.0 true
1125
+
2 │ 4 0.0 false
1126
+
3 │ 5 2.0 true
1127
+
```
1064
1128
"""
1065
1129
function Base.filter(ds::AbstractDataset, cols::Union{ColumnIndex, MultiColumnIndex}; view =false, type= all, kwargs...)
1066
1130
if view
@@ -1072,9 +1136,15 @@ end
1072
1136
"""
1073
1137
filter!(ds, cols; [type = all, ...])
1074
1138
1075
-
A convenient shortcut for deleteat![ds, .!byrow(ds, type, cols; ...)). `type` can be any function supported by `byrow` which returns a Vector{Bool} or BitVector.
1139
+
Variant of `filter` which replaces the passed data set with the filtered one.
1140
+
1141
+
It is a convenient shortcut for `deleteat![ds, .!byrow(ds, type, cols; ...)]`.
1142
+
1143
+
`type` can be any function supported by `byrow` which returns a Vector{Bool} or BitVector.
1144
+
1145
+
Refer to [`filter`](@ref) for exmaples.
1076
1146
1077
-
See [`byrow`](@ref)
1147
+
See [`byrow`](@ref), [`filter`](@ref)
1078
1148
"""
1079
1149
Base.filter!(ds::Dataset, cols::Union{ColumnIndex, MultiColumnIndex}; type = all, kwargs...) =deleteat!(ds, .!byrow(ds, type, cols; kwargs...))
0 commit comments