@@ -255,18 +255,49 @@ julia> df[!, Not(:x1)]
255255Finally, you can use ` Not ` , ` Between ` , ` Cols ` and ` All ` selectors in more
256256complex column selection scenarios (note that ` Cols() ` selects no columns while
257257` All() ` selects all columns therefore ` Cols ` is a preferred selector if you
258- write generic code). The following examples move all columns whose names match
259- ` r"x" ` regular expression respectively to the front and to the end of a data
260- frame:
258+ write generic code). Here are examples of using each of these selectors:
261259
262- ```
260+ ``` jldoctest dataframe
263261julia> df = DataFrame(r=1, x1=2, x2=3, y=4)
2642621×4 DataFrame
265263 Row │ r x1 x2 y
266264 │ Int64 Int64 Int64 Int64
267265─────┼────────────────────────────
268266 1 │ 1 2 3 4
269267
268+ julia> df[:, Not(:r)] # drop :r column
269+ 1×3 DataFrame
270+ Row │ x1 x2 y
271+ │ Int64 Int64 Int64
272+ ─────┼─────────────────────
273+ 1 │ 2 3 4
274+
275+ julia> df[:, Between(:r, :x2)] # keep columns between :r and :x2
276+ 1×3 DataFrame
277+ Row │ r x1 x2
278+ │ Int64 Int64 Int64
279+ ─────┼─────────────────────
280+ 1 │ 1 2 3
281+
282+ julia> df[:, All()] # keep all columns
283+ 1×4 DataFrame
284+ Row │ r x1 x2 y
285+ │ Int64 Int64 Int64 Int64
286+ ─────┼────────────────────────────
287+ 1 │ 1 2 3 4
288+
289+ julia> df[:, Cols(x -> startswith(x, "x"))] # keep columns whose name starts with "x"
290+ 1×2 DataFrame
291+ Row │ x1 x2
292+ │ Int64 Int64
293+ ─────┼──────────────
294+ 1 │ 2 3
295+ ```
296+
297+ The following examples show a more complex use of the ` Cols ` selector, which moves all
298+ columns whose names match ` r"x" ` regular expression respectively to the front
299+ and to the end of the data frame:
300+ ``` jldoctest dataframe
270301julia> df[:, Cols(r"x", :)]
2713021×4 DataFrame
272303 Row │ x1 x2 r y
0 commit comments