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
Copy file name to clipboardExpand all lines: docs/src/man/modify.md
+28-2Lines changed: 28 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,11 +12,11 @@ The first argument of these two functions is the name of the data set which is g
12
12
13
13
> `modify!(ds, args...)` or `modify(ds, args...)`
14
14
15
-
The simplest form of `args` is `col => fun` which calls `fun` on `col` as a vector and replaces `col` with the output of the call. `col` can be a column index or a column name. Thus, to replace the value of a column which is called `:x1` in a data set `ds` with their standardised values, we can use the following expression:
15
+
The simplest form of `args` is `col => fun` which calls `fun` on `col` as a vector and **replaces**`col` with the output of the call. `col` can be a column index or a column name. Thus, to replace the value of a column which is called `:x1` in a data set `ds` with their standardised values, we can use the following expression:
16
16
17
17
> `modify!(ds, :x1 => stdze)`
18
18
19
-
where `:x1` is a column in `ds`, and `stdze` is a function which subtracts values by their mean and divide them by their standard deviation. If you don't want to replace the column, but instead you like to create a new column based on calling `fun` on `col`, the `col => fun => :newname` (here `:newname` is a name for the new column) form is handy. Thus, to standardised the values of a column, which is called `:x1`, and store them as a new column in the data set, you can use,
19
+
where `:x1` is a column in `ds`, and `stdze` is a function which subtracts values by their mean and divide them by their standard deviation. If you don't want to replace the column, but instead you like to create a new column based on calling `fun` on `col`, the `col => fun => :newname` (here `:newname` is a name for the new column) form is handy. Thus, to standardised the values of a column, which is called `:x1`, and store them as a new column in the data set, you can use,
In the last example, we use `byrow` to apply `name_split` on each row of `:customer`, and since there is only one column as the input of `byrow`, `modify!` replaces the column with the new values. Also, note that the `modify!` function has access to these new values and we can use `splitter` to split the column into two new columns.
179
+
180
+
## Using `Tuple` of column names
181
+
182
+
When the form of the transform specifications is as `NTuple{col} => fun`, `modify!` and `modify` assumes that the `fun` function accepts multiple arguments (multiple columns).
0 commit comments