Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/safeds/data/tabular/containers/_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,22 +1007,22 @@ def transform_column(
# ------------------------------------------------------------------------------------------------------------------

@overload
def count_row_if(
def count_rows_if(
self,
predicate: Callable[[Row], Cell[bool | None]],
*,
ignore_unknown: Literal[True] = ...,
) -> int: ...

@overload
def count_row_if(
def count_rows_if(
self,
predicate: Callable[[Row], Cell[bool | None]],
*,
ignore_unknown: bool,
) -> int | None: ...

def count_row_if(
def count_rows_if(
self,
predicate: Callable[[Row], Cell[bool | None]],
*,
Expand Down Expand Up @@ -1059,10 +1059,10 @@ def count_row_if(
--------
>>> from safeds.data.tabular.containers import Table
>>> table = Table({"col1": [1, 2, 3], "col2": [1, 3, 3]})
>>> table.count_row_if(lambda row: row["col1"] == row["col2"])
>>> table.count_rows_if(lambda row: row["col1"] == row["col2"])
2

>>> table.count_row_if(lambda row: row["col1"] > row["col2"])
>>> table.count_rows_if(lambda row: row["col1"] > row["col2"])
0
"""
expression = predicate(_LazyVectorizedRow(self))._polars_expression
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

from safeds.data.tabular.containers import Table


Expand Down Expand Up @@ -30,7 +31,7 @@ def test_should_handle_boolean_logic(
expected: int,
) -> None:
table = Table({"a": values})
assert table.count_row_if(lambda row: row["a"] < 2) == expected
assert table.count_rows_if(lambda row: row["a"] < 2) == expected


@pytest.mark.parametrize(
Expand Down Expand Up @@ -61,4 +62,4 @@ def test_should_handle_kleene_logic(
expected: int | None,
) -> None:
table = Table({"a": values})
assert table.count_row_if(lambda row: row["a"] < 2, ignore_unknown=False) == expected
assert table.count_rows_if(lambda row: row["a"] < 2, ignore_unknown=False) == expected