Skip to content

Commit 8637aeb

Browse files
committed
Update modify.md
1 parent 4c6e194 commit 8637aeb

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

docs/src/man/modify.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Transforming data sets
22

3-
# Introduction
3+
## Introduction
44

55
The `modify!` function can be used to transform and modify columns of a data set. Note that the function modifies the data set in-place and operates on actual values (rather than the formatted values). To modify a copy of data we should use the `modify` function. These two functions accept one column of data set and apply the provided functions on the fed column as a vector, this should be compared to `map!/map` functions which apply operations on individual observations.
66

77
> Note that `modify!/modify` remove the format of columns as soon as their values are updated by a given transformation.
88
9-
# Specifying the transformation
9+
## Specifying the transformation
1010

1111
The first argument of these two functions is the name of the data set which is going to be modified and the next arguments can be the transform specifications, i.e.
1212

@@ -39,7 +39,7 @@ will be translated as:
3939

4040
>`:x1 => sum => :x1_sum, :x1 => sort => :x1_sort`.
4141
42-
## Examples
42+
### Examples
4343

4444
```jldoctest
4545
julia> ds = Dataset(x1 = 1:5, x2 = [-2, -1, missing, 1, 2],
@@ -80,16 +80,16 @@ julia> modify!(ds, :x1 => x -> x .- mean(x))
8080
5 │ 2.0 0 0.7
8181
```
8282

83-
# Accessing to modified columns
83+
## Accessing to modified columns
8484

8585
One of the key features of `modify!/modify` is that these functions have access to all modified/created variable in a single run of the function. It means, every transformation can be done on all columns that have been or updated by `args` arguments or any column which is created by `col => fun => :newname` syntax. In other words, for `args...` from left to right whenever a column is updated or created, the next operation has access to its value (either new or updated values). This will be particularly useful in conjunction with `byrow` which performs row-wise operations.
8686

8787

88-
# Specialised functions
88+
## Specialised functions
8989

9090
There are two functions in Datasets which are very handy to modify a data set: `byrow`, and `splitter`.
9191

92-
## `byrow`
92+
### `byrow`
9393

9494
The `byrow` function is discussed in length in another section as a stand-alone function, however, it can also be used as the `fun` when we want to specify the transformation in `modify!/modify`. The syntax of `byrow` is different from its stand-alone usage in the way that when `byrow` is the `fun` part of `args` in the syntax of `modify!/modify` functions, we don't need to specify `ds` and `cols`, however, every other arguments are the same as the stand-alone usage.
9595

@@ -101,7 +101,7 @@ The form of `args` when `byrow` is the function is similar to other functions wi
101101
* When `col` refers to a single column in `col => byrow(...)`, `modify!/modify` will apply operation on single values of the column and replace the column with the new values, i.e. it doesn't create a new column.
102102
* To use broadcasting with `byrow`, i.e. applying the same row-wise operation on multiple columns, the form must be `cols .=> byrow` where `cols` is a vector of column names or column indices (regular expression cannot be used for this purpose).
103103

104-
## `splitter`
104+
### `splitter`
105105

106106
`splitter` is also a specialised function which has a single job: splitting a single column which is a `Tuple` of values into multiple columns. It only operates on a single columns and the values inside the column which needs to be split must be in the form of `Tuples`. The form of `args` for `splitter` must be similar to:
107107

@@ -111,7 +111,7 @@ which means we like to split `col` into two new columns; `:new_col_1` and `:new_
111111

112112
> Note, `splitter` produces as many columns as the length of the given new names, i.e. if the user provides fewer names than needed, the output columns will only contain partial components of the input `Tuple`.
113113
114-
## Examples
114+
### Examples
115115

116116
```jldoctest
117117
julia> body = Dataset(weight = [78.5, 59, 80], height = [160, 171, 183])

0 commit comments

Comments
 (0)