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
In Julia, missing values in data are represented using the special object `missing`, which is the single instance of the type `Missing`.
3
+
In Julia, missing values in data are represented using the special object
4
+
`missing`, which is the single instance of the type `Missing`.
4
5
5
6
```jldoctest
6
7
julia> missing
7
8
missing
8
9
9
10
julia> typeof(missing)
10
11
Missing
11
-
12
12
```
13
13
14
-
The `Missing` type lets users create `Vector`s and `DataFrame` columns with missing values. Here we create a vector with a missing value and the element-type of the returned vector is `Union{Missing, Int64}`.
14
+
The `Missing` type lets users create vectors and `DataFrame` columns with
15
+
missing values. Here we create a vector with a missing value and the
16
+
element-type of the returned vector is `Union{Missing, Int64}`.
15
17
16
18
```jldoctest missings
17
19
julia> x = [1, 2, missing]
@@ -28,18 +30,19 @@ Union{Missing, Int64}
28
30
29
31
julia> eltype(x) == Union{Missing, Int}
30
32
true
31
-
32
33
```
33
34
34
-
`missing` values can be excluded when performing operations by using `skipmissing`, which returns a memory-efficient iterator.
35
+
`missing` values can be excluded when performing operations by using
36
+
`skipmissing`, which returns a memory-efficient iterator.
35
37
36
38
```jldoctest missings
37
39
julia> skipmissing(x)
38
40
skipmissing(Union{Missing, Int64}[1, 2, missing])
39
-
40
41
```
41
42
42
-
The output of `skipmissing` can be passed directly into functions as an argument. For example, we can find the `sum` of all non-missing values or `collect` the non-missing values into a new missing-free vector.
43
+
The output of `skipmissing` can be passed directly into functions as an
44
+
argument. For example, we can find the `sum` of all non-missing values or
45
+
`collect` the non-missing values into a new missing-free vector.
The function `coalesce` can be used to replace missing values with another value (note the dot, indicating that the replacement should be applied to all entries in `x`):
57
+
The function `coalesce` can be used to replace missing values with another value
58
+
(note the dot, indicating that the replacement should be applied to all entries
59
+
in `x`):
56
60
57
61
```jldoctest missings
58
62
julia> coalesce.(x, 0)
59
63
3-element Vector{Int64}:
60
64
1
61
65
2
62
66
0
63
-
64
67
```
65
68
66
-
The functions `dropmissing` and `dropmissing!` can be used to remove the rows containing `missing` values from a `DataFrame` and either create a new `DataFrame` or mutate the original in-place respectively.
69
+
The functions [`dropmissing`](@ref) and [`dropmissing!`](@ref) can be used to
70
+
remove the rows containing `missing` values from a data frame and either create
71
+
a new `DataFrame` or mutate the original in-place respectively.
67
72
68
73
```jldoctest missings
69
74
julia> using DataFrames
@@ -90,7 +95,8 @@ julia> dropmissing(df)
90
95
2 │ 5 1 e
91
96
```
92
97
93
-
One can specify the column(s) in which to search for rows containing `missing` values to be removed.
98
+
One can specify the column(s) in which to search for rows containing `missing`
99
+
values to be removed.
94
100
95
101
```jldoctest missings
96
102
julia> dropmissing(df, :x)
@@ -103,10 +109,10 @@ julia> dropmissing(df, :x)
103
109
3 │ 5 1 e
104
110
```
105
111
106
-
By default the `dropmissing` and `dropmissing!` functions keep the
107
-
`Union{T, Missing}` element type in columns selected for row removal. To remove
108
-
the `Missing` part, if present, set the `disallowmissing`option to `true` (it
109
-
will become the default behavior in the future).
112
+
By default the [`dropmissing`](@ref) and [`dropmissing!`](@ref) functions keep
113
+
the `Union{T, Missing}` element type in columns selected for row removal. To
114
+
remove the `Missing` part, if present, set the `disallowmissing`keyword
115
+
argument to `true` (it will become the default behavior in the future).
0 commit comments