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: CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,12 @@
2
2
3
3
## New features
4
4
5
+
* A new functionality has been added to `byrow` for passing a Tuple of column indices. `byrow(ds, fun, cols)` calls `fun.(ds[:, cols[1]], ds[:, cols[2]], ...)` when `cols` is a NTuple of column indices.
6
+
7
+
# Version 0.7.6
8
+
9
+
## New features
10
+
5
11
* Two new functions: `delete` and `delete!`. They should be compared to `filter` and `filter!`, respectively - [issue #63](https://github.com/sl-solution/InMemoryDatasets.jl/issues/63)
6
12
* Add `DLMReader` to `sysimage` in `IMD.create_sysimage`.
Copy file name to clipboardExpand all lines: docs/src/man/byrow.md
+28-1Lines changed: 28 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -237,7 +237,9 @@ One special function that can be used as `fun` in the `byrow` function is `mapre
237
237
238
238
## User defined operations
239
239
240
-
For user defined functions which return a single value, `byrow` treats each row as a vector of values, thus the user defined function must accept a vector and returns a single value. For instance to calculate `1 * col1 + 2 * col2 + 3 * col3` for each row in `ds` we can define the following function:
240
+
For user defined functions which return a single value, `byrow` treats each row as a vector of values, thus the user defined function must accept a vector and returns a single value.
241
+
However, when user defines a multivariate function and pass a Tuple of column indices as the `cols` argument of `byrow`, the `byrow` function simply calls `fun.(ds[:, cols[1]], ds[:, cols2], ...)`.
242
+
For instance to calculate `1 * col1 + 2 * col2 + 3 * col3` for each row in `ds` we can define the following function:
241
243
242
244
```jldoctest
243
245
julia> avg(x) = 1 * x[1] + 2 * x[2] + 3 * x[3]
@@ -258,6 +260,31 @@ julia> byrow(ds, avg, 1:3)
258
260
259
261
Note that `avg` is missing if any of the values in `x` is missing.
260
262
263
+
Below is an example of using `byrow` with a user defined multivariate function
`byrow` also supports a few optimised operations which return a vector of values for each row. The `fun` argument for these operations is one of the followings:
Copy file name to clipboardExpand all lines: src/byrow/doc.jl
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1238,8 +1238,9 @@ Return the result of calling `fun` on each row of `ds` selected by `cols`. The `
1238
1238
1239
1239
When user passes a type as `fun` and a single column as `cols`, `byrow` convert the corresponding column to the type specified by `fun`.
1240
1240
1241
-
For generic functions there are two special cases:
1241
+
For generic functions there are the below special cases:
1242
1242
1243
1243
* When `cols` is a single column, `byrow(ds, fun, cols)` acts like `fun.(ds[:, cols])`
1244
1244
* When `cols` is referring to exactly two columns and it is possible to pass two vectors as arguments of `fun`, `byrow` returns `fun.(ds[:, col1], ds[:, col2])` when possible.
1245
+
* When `cols` is a `Tuple` of column indices, `byrow(ds, fun, cols)` returns `fun.(ds[:, cols[1]], ds[:, cols[2]], ...)`, i.e. `fun` is a multivariate function which will be applied on each row of `cols`.
!(_is_byrow_valid(Index(newlookup, new_nm, Dict{Int, Function}()), ms)) &&throw(ArgumentError("`byrow` must be used for aggregated columns, use `modify` otherwise"))
0 commit comments