def test_non_exact_strptime() -> None: a = pl.Series("a", ["2022-01-16", "2022-01-17", "foo2022-01-18", "b2022-01-19ar"]) fmt = "%Y-%m-%d" expected = pl.Series("a", [date(2022, 1, 16), date(2022, 1, 17), None, None]) verify_series_and_expr_api( a, expected, "str.strptime", pl.Date, fmt, strict=False, exact=True ) expected = pl.Series( "a", [date(2022, 1, 16), date(2022, 1, 17), date(2022, 1, 18), date(2022, 1, 19)], ) verify_series_and_expr_api( a, expected, "str.strptime", pl.Date, fmt, strict=False, exact=False ) with pytest.raises(Exception): a.str.strptime(pl.Date, fmt, strict=True, exact=True)
def test_list_join_strings() -> None: s = pl.Series("a", [["ab", "c", "d"], ["e", "f"], ["g"], []]) expected = pl.Series("a", ["ab-c-d", "e-f", "g", ""]) verify_series_and_expr_api(s, expected, "arr.join", "-")
def test_unique_stable() -> None: a = pl.Series("a", [1, 1, 1, 1, 2, 2, 2, 3, 3]) expected = pl.Series("a", [1, 2, 3]) verify_series_and_expr_api(a, expected, "unique", True)
def test_unique_counts() -> None: s = pl.Series("id", ["a", "b", "b", "c", "c", "c"]) expected = pl.Series("id", [1, 2, 3], dtype=pl.UInt32) verify_series_and_expr_api(s, expected, "unique_counts")
def test_list_argminmax() -> None: s = pl.Series("a", [[1, 2], [3, 2, 1]]) expected = pl.Series("a", [0, 2], dtype=pl.UInt32) verify_series_and_expr_api(s, expected, "arr.arg_min") expected = pl.Series("a", [1, 0], dtype=pl.UInt32) verify_series_and_expr_api(s, expected, "arr.arg_max")