@@ -50,6 +50,7 @@ selector (this is useful in particular with regular expressions, `Cols`, `Not`,
5050See also [`propertynames`](@ref) which returns a `Vector{Symbol}`.
5151
5252# Examples
53+
5354```jldoctest
5455julia> df = DataFrame(x1=[1, missing, missing], x2=[3, 2, 4], x3=[3, missing, 2], x4=Union{Int, Missing}[2, 4, 4])
55563×4 DataFrame
@@ -154,6 +155,7 @@ when a column is renamed, its `:note`-style metadata becomes associated to its n
154155See also: [`rename`](@ref)
155156
156157# Examples
158+
157159```jldoctest
158160julia> df = DataFrame(i=1, x=2, y=3)
1591611×3 DataFrame
@@ -298,6 +300,7 @@ new name.
298300See also: [`rename!`](@ref)
299301
300302# Examples
303+
301304```jldoctest
302305julia> df = DataFrame(i=1, x=2, y=3)
3033061×3 DataFrame
@@ -359,6 +362,7 @@ and `2` corresponds to columns.
359362See also: [`nrow`](@ref), [`ncol`](@ref)
360363
361364# Examples
365+
362366```jldoctest
363367julia> df = DataFrame(a=1:3, b='a':'c');
364368
@@ -610,6 +614,7 @@ access missing values.
610614Metadata: this function drops all metadata.
611615
612616# Examples
617+
613618```jldoctest
614619julia> df = DataFrame(i=1:10, x=0.1:0.1:1.0, y='a':'j');
615620
@@ -1087,6 +1092,7 @@ $METADATA_FIXED
10871092See also: [`filter!`](@ref)
10881093
10891094# Examples
1095+
10901096```jldoctest
10911097julia> df = DataFrame(x=[3, 1, 2, 1], y=["b", "c", "a", "b"])
109210984×2 DataFrame
@@ -1216,6 +1222,7 @@ $METADATA_FIXED
12161222See also: [`filter`](@ref)
12171223
12181224# Examples
1225+
12191226```jldoctest
12201227julia> df = DataFrame(x=[3, 1, 2, 1], y=["b", "c", "a", "b"])
122112284×2 DataFrame
@@ -1353,6 +1360,7 @@ See also [`unique`](@ref) and [`unique!`](@ref).
13531360 returns at least one column if `df` has at least one column.
13541361
13551362# Examples
1363+
13561364```jldoctest
13571365julia> df = DataFrame(i=1:4, x=[1, 2, 1, 2])
135813664×2 DataFrame
@@ -1446,6 +1454,7 @@ $METADATA_FIXED
14461454See also: [`unique!`](@ref), [`nonunique`](@ref).
14471455
14481456# Examples
1457+
14491458```jldoctest
14501459julia> df = DataFrame(i=1:4, x=[1, 2, 1, 2])
145114604×2 DataFrame
@@ -1520,6 +1529,7 @@ $METADATA_FIXED
15201529See also: [`unique!`](@ref), [`nonunique`](@ref).
15211530
15221531# Examples
1532+
15231533```jldoctest
15241534julia> df = DataFrame(i=1:4, x=[1, 2, 1, 2])
152515354×2 DataFrame
@@ -1582,6 +1592,7 @@ duplicates are allowed.
15821592$METADATA_FIXED
15831593
15841594# Examples
1595+
15851596```jldoctest
15861597julia> df = DataFrame(x=1:2, y='a':'b', z=["x", "y"])
158715982×3 DataFrame
@@ -2812,6 +2823,8 @@ $METADATA_FIXED
28122823Metadata having other styles is dropped (from parent data frame when `df` is a `SubDataFrame`).
28132824
28142825# Examples
2826+
2827+ ```jldoctest
28152828julia> df = DataFrame(a=1:5, b=6:10, c=11:15)
281628295×3 DataFrame
28172830 Row │ a b c
@@ -2833,6 +2846,7 @@ julia> permute!(df, [5, 3, 1, 2, 4])
28332846 3 │ 1 6 11
28342847 4 │ 2 7 12
28352848 5 │ 4 9 14
2849+ ```
28362850"""
28372851Base. permute! (df:: AbstractDataFrame , p:: AbstractVector{<:Integer} ) =
28382852 _permutation_helper! (Base. permute!!, df, p)
@@ -2852,6 +2866,7 @@ Metadata having other styles is dropped (from parent data frame when `df` is a `
28522866
28532867# Examples
28542868
2869+ ```jldoctest
28552870julia> df = DataFrame(a=1:5, b=6:10, c=11:15)
285628715×3 DataFrame
28572872 Row │ a b c
@@ -2884,6 +2899,7 @@ julia> invpermute!(df, [5, 3, 1, 2, 4])
28842899 3 │ 3 8 13
28852900 4 │ 4 9 14
28862901 5 │ 5 10 15
2902+ ```
28872903"""
28882904Base. invpermute! (df:: AbstractDataFrame , p:: AbstractVector{<:Integer} ) =
28892905 _permutation_helper! (Base. invpermute!!, df, p)
@@ -2898,6 +2914,9 @@ $METADATA_FIXED
28982914
28992915# Examples
29002916
2917+ ```jldoctest
2918+ julia> using Random
2919+
29012920julia> rng = MersenneTwister(1234);
29022921
29032922julia> shuffle(rng, DataFrame(a=1:5, b=1:5))
@@ -2910,6 +2929,7 @@ julia> shuffle(rng, DataFrame(a=1:5, b=1:5))
29102929 3 │ 4 4
29112930 4 │ 3 3
29122931 5 │ 5 5
2932+ ```
29132933"""
29142934Random. shuffle (df:: AbstractDataFrame ) =
29152935 df[randperm (nrow (df)), :]
@@ -2932,6 +2952,9 @@ Metadata having other styles is dropped (from parent data frame when `df` is a `
29322952
29332953# Examples
29342954
2955+ ```jldoctest
2956+ julia> using Random
2957+
29352958julia> rng = MersenneTwister(1234);
29362959
29372960julia> shuffle!(rng, DataFrame(a=1:5, b=1:5))
@@ -2944,6 +2967,7 @@ julia> shuffle!(rng, DataFrame(a=1:5, b=1:5))
29442967 3 │ 4 4
29452968 4 │ 3 3
29462969 5 │ 5 5
2970+ ```
29472971"""
29482972Random. shuffle! (df:: AbstractDataFrame ) =
29492973 permute! (df, randperm (nrow (df)))
0 commit comments