Skip to content

Commit

Permalink
docs: use indexed access in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann committed Nov 1, 2024
1 parent 3752201 commit 4f39607
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
8 changes: 5 additions & 3 deletions docs/api/safeds/data/tabular/containers/Row.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ This class cannot be instantiated directly. It is only used for arguments of cal
* pipeline example {
* val table = Table({"col1": [1, 2], "col2": [3, 4]});
* val result = table.removeRows((row) -> row.getValue("col1") == 1);
* }
*
* @example
* pipeline example {
Expand Down Expand Up @@ -117,7 +118,7 @@ Get the type of the specified column.

??? quote "Stub code in `Row.sdsstub`"

```sds linenums="57"
```sds linenums="58"
@Pure
@PythonName("get_column_type")
fun getColumnType(
Expand Down Expand Up @@ -147,6 +148,7 @@ Get the value of the specified column. This is equivalent to the `[]` operator (
pipeline example {
val table = Table({"col1": [1, 2], "col2": [3, 4]});
val result = table.removeRows((row) -> row.getValue("col1") == 1);
}
```
```sds
pipeline example {
Expand All @@ -158,7 +160,7 @@ pipeline example {

??? quote "Stub code in `Row.sdsstub`"

```sds linenums="44"
```sds linenums="45"
@Pure
@PythonName("get_value")
fun getValue(
Expand All @@ -184,7 +186,7 @@ Check if the row has a column with the specified name.

??? quote "Stub code in `Row.sdsstub`"

```sds linenums="70"
```sds linenums="71"
@Pure
@PythonName("has_column")
fun hasColumn(
Expand Down
20 changes: 10 additions & 10 deletions docs/api/safeds/data/tabular/containers/Table.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pipeline example {
* @example
* pipeline example {
* val table = Table({"a": [1, 2, 3], "b": [4, 5, 6]});
* val result = table.addComputedColumn("c", (row) -> row.getValue("a") + row.getValue("b"));
* val result = table.addComputedColumn("c", (row) -> row["a"] + row["b"]);
* }
*/
@Pure
Expand Down Expand Up @@ -468,13 +468,13 @@ pipeline example {
* @example
* pipeline example {
* val table = Table({"col1": [1, 2, 3], "col2": [1, 3, 3]});
* val result = table.countRowIf((row) -> row.getValue("col1") == row.getValue("col2")); // 2
* val result = table.countRowIf((row) -> row["col1"] == row["col2"]); // 2
* }
*
* @example
* pipeline example {
* val table = Table({"col1": [1, 2, 3], "col2": [1, 3, 3]});
* val result = table.countRowIf((row) -> row.getValue("col1") > row.getValue("col2")); // 0
* val result = table.countRowIf((row) -> row["col1"] > row["col2"]); // 0
* }
*/
@Pure
Expand Down Expand Up @@ -514,7 +514,7 @@ pipeline example {
* @example
* pipeline example {
* val table = Table({"a": [1, 2, 3], "b": [4, 5, 6]});
* val result = table.removeRows((row) -> row.getValue("a") == 2);
* val result = table.removeRows((row) -> row["a"] == 2);
* // Table({"a": [1, 3], "b": [4, 6]})
* }
*/
Expand Down Expand Up @@ -673,7 +673,7 @@ pipeline example {
* @example
* pipeline example {
* val table = Table({"a": [2, 1, 3], "b": [1, 1, 2]});
* val result = table.sortRows((row) -> row.getValue("a") - row.getValue("b"));
* val result = table.sortRows((row) -> row["a"] - row["b"]);
* // Table({"a": [1, 2, 3], "b": [1, 1, 2]})
* }
*/
Expand Down Expand Up @@ -1147,7 +1147,7 @@ Return a new table with an additional computed column.
```sds hl_lines="3"
pipeline example {
val table = Table({"a": [1, 2, 3], "b": [4, 5, 6]});
val result = table.addComputedColumn("c", (row) -> row.getValue("a") + row.getValue("b"));
val result = table.addComputedColumn("c", (row) -> row["a"] + row["b"]);
}
```

Expand Down Expand Up @@ -1280,13 +1280,13 @@ if the predicate returns null at least once. Otherwise, it still returns how oft
```sds hl_lines="3"
pipeline example {
val table = Table({"col1": [1, 2, 3], "col2": [1, 3, 3]});
val result = table.countRowIf((row) -> row.getValue("col1") == row.getValue("col2")); // 2
val result = table.countRowIf((row) -> row["col1"] == row["col2"]); // 2
}
```
```sds hl_lines="3"
pipeline example {
val table = Table({"col1": [1, 2, 3], "col2": [1, 3, 3]});
val result = table.countRowIf((row) -> row.getValue("col1") > row.getValue("col2")); // 0
val result = table.countRowIf((row) -> row["col1"] > row["col2"]); // 0
}
```

Expand Down Expand Up @@ -1690,7 +1690,7 @@ Return a new table without rows that satisfy a condition.
```sds hl_lines="3"
pipeline example {
val table = Table({"a": [1, 2, 3], "b": [4, 5, 6]});
val result = table.removeRows((row) -> row.getValue("a") == 2);
val result = table.removeRows((row) -> row["a"] == 2);
// Table({"a": [1, 3], "b": [4, 6]})
}
```
Expand Down Expand Up @@ -2044,7 +2044,7 @@ Return a new table with the rows sorted.
```sds hl_lines="3"
pipeline example {
val table = Table({"a": [2, 1, 3], "b": [1, 1, 2]});
val result = table.sortRows((row) -> row.getValue("a") - row.getValue("b"));
val result = table.sortRows((row) -> row["a"] - row["b"]);
// Table({"a": [1, 2, 3], "b": [1, 1, 2]})
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Row {
* pipeline example {
* val table = Table({"col1": [1, 2], "col2": [3, 4]});
* val result = table.removeRows((row) -> row.getValue("col1") == 1);
* }
*
* @example
* pipeline example {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class Table(
* @example
* pipeline example {
* val table = Table({"a": [1, 2, 3], "b": [4, 5, 6]});
* val result = table.addComputedColumn("c", (row) -> row.getValue("a") + row.getValue("b"));
* val result = table.addComputedColumn("c", (row) -> row["a"] + row["b"]);
* }
*/
@Pure
Expand Down Expand Up @@ -466,13 +466,13 @@ class Table(
* @example
* pipeline example {
* val table = Table({"col1": [1, 2, 3], "col2": [1, 3, 3]});
* val result = table.countRowIf((row) -> row.getValue("col1") == row.getValue("col2")); // 2
* val result = table.countRowIf((row) -> row["col1"] == row["col2"]); // 2
* }
*
* @example
* pipeline example {
* val table = Table({"col1": [1, 2, 3], "col2": [1, 3, 3]});
* val result = table.countRowIf((row) -> row.getValue("col1") > row.getValue("col2")); // 0
* val result = table.countRowIf((row) -> row["col1"] > row["col2"]); // 0
* }
*/
@Pure
Expand Down Expand Up @@ -512,7 +512,7 @@ class Table(
* @example
* pipeline example {
* val table = Table({"a": [1, 2, 3], "b": [4, 5, 6]});
* val result = table.removeRows((row) -> row.getValue("a") == 2);
* val result = table.removeRows((row) -> row["a"] == 2);
* // Table({"a": [1, 3], "b": [4, 6]})
* }
*/
Expand Down Expand Up @@ -671,7 +671,7 @@ class Table(
* @example
* pipeline example {
* val table = Table({"a": [2, 1, 3], "b": [1, 1, 2]});
* val result = table.sortRows((row) -> row.getValue("a") - row.getValue("b"));
* val result = table.sortRows((row) -> row["a"] - row["b"]);
* // Table({"a": [1, 2, 3], "b": [1, 1, 2]})
* }
*/
Expand Down

0 comments on commit 4f39607

Please sign in to comment.