diff --git a/docs/api/safeds/data/tabular/containers/Row.md b/docs/api/safeds/data/tabular/containers/Row.md index 8b478445f..d43d6bab8 100644 --- a/docs/api/safeds/data/tabular/containers/Row.md +++ b/docs/api/safeds/data/tabular/containers/Row.md @@ -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 { @@ -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( @@ -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 { @@ -158,7 +160,7 @@ pipeline example { ??? quote "Stub code in `Row.sdsstub`" - ```sds linenums="44" + ```sds linenums="45" @Pure @PythonName("get_value") fun getValue( @@ -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( diff --git a/docs/api/safeds/data/tabular/containers/Table.md b/docs/api/safeds/data/tabular/containers/Table.md index cd5fd4e8d..d9cde7f20 100644 --- a/docs/api/safeds/data/tabular/containers/Table.md +++ b/docs/api/safeds/data/tabular/containers/Table.md @@ -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 @@ -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 @@ -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]}) * } */ @@ -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]}) * } */ @@ -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"]); } ``` @@ -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 } ``` @@ -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]}) } ``` @@ -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]}) } ``` diff --git a/packages/safe-ds-lang/src/resources/builtins/safeds/data/tabular/containers/Row.sdsstub b/packages/safe-ds-lang/src/resources/builtins/safeds/data/tabular/containers/Row.sdsstub index f70b76d25..f11b3e0e6 100644 --- a/packages/safe-ds-lang/src/resources/builtins/safeds/data/tabular/containers/Row.sdsstub +++ b/packages/safe-ds-lang/src/resources/builtins/safeds/data/tabular/containers/Row.sdsstub @@ -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 { diff --git a/packages/safe-ds-lang/src/resources/builtins/safeds/data/tabular/containers/Table.sdsstub b/packages/safe-ds-lang/src/resources/builtins/safeds/data/tabular/containers/Table.sdsstub index 07f3cec08..b5fd326d7 100644 --- a/packages/safe-ds-lang/src/resources/builtins/safeds/data/tabular/containers/Table.sdsstub +++ b/packages/safe-ds-lang/src/resources/builtins/safeds/data/tabular/containers/Table.sdsstub @@ -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 @@ -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 @@ -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]}) * } */ @@ -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]}) * } */