def test_concat_str() -> None: df = pl.DataFrame({"a": ["a", "b", "c"], "b": [1, 2, 3]}) out = df[[pl.concat_str(["a", "b"], sep="-")]] assert out["a"] == ["a-1", "a-2", "a-3"] out = df.select([pl.format("foo_{}_bar_{}", pl.col("a"), "b").alias("fmt")]) assert out["fmt"].to_list() == ["foo_a_bar_1", "foo_b_bar_2", "foo_c_bar_3"]
def test_wildcard_expansion() -> None: # one function requires wildcard expansion the other need # this tests the nested behavior # see: #2867 df = pl.DataFrame({"a": ["x", "Y", "z"], "b": ["S", "o", "S"]}) assert df.select( pl.concat_str(pl.all()).str.to_lowercase() ).to_series().to_list() == ["xs", "yo", "zs"]
def test_concat_str(): df = pl.DataFrame({"a": ["a", "b", "c"], "b": [1, 2, 3]}) out = df[[pl.concat_str(["a", "b"], delimiter="-")]] assert out["a"] == ["a-1", "a-2", "a-3"]
import polars as pl df = pl.DataFrame({"a": ["a", "b", "c"], "b": [1, 2, 3]}) out = df[[pl.concat_str(["a", "b"])]]