Вот пример.
Код: Выделить всё
import polars as pl
pl.Config(fmt_table_cell_list_len=10, fmt_str_lengths=100)
df = pl.DataFrame({"libs": [["aa", "bb", "cc",], ["dd", "ee", "ff"]]})
Код: Выделить всё
# Output:
shape: (2, 1)
┌────────────────────┐
│ libs │
│ --- │
│ list[str] │
╞════════════════════╡
│ ["aa", "bb", "cc"] │
│ ["dd", "ee", "ff"] │
└────────────────────┘
Код: Выделить всё
df.with_columns(pl.col("libs").list.concat([pl.lit("gg"), pl.lit("hh")]))
# Output
shape: (2, 1)
┌────────────────────────────────┐
│ libs │
│ --- │
│ list[str] │
╞════════════════════════════════╡
│ ["aa", "bb", "cc", "gg", "hh"] │
│ ["dd", "ee", "ff", "gg", "hh"] │
└────────────────────────────────┘
Код: Выделить всё
df.with_columns(pl.col("libs").list.concat(["gg", "hh"]))
# ---------------------------------------------------------------------------
# ColumnNotFoundError Traceback (most recent call last)
# Cell In[12], line 1
# ----> 1 df.with_columns(pl.col("libs").list.concat(["dd", "ee"]))
#
# ColumnNotFoundError: unable to find column "dd"; valid columns: ["libs"]
Подробнее здесь: https://stackoverflow.com/questions/765 ... pe-liststr
Мобильная версия