str.strip

ColExpr.str.strip() ColExpr[String][source]

Removes leading and trailing whitespace.

Examples

>>> t = pdt.Table(
...     {
...         "a": ["  BCD ", "-- 00", " A^^u", "-O2"],
...         "b": ["12431", "transform", "12__*m", "   "],
...     },
...     name="string table",
... )
>>> t >> mutate(j=t.a.str.strip(), k=t.b.str.strip()) >> show()
Table string table, backend: PolarsImpl
shape: (4, 4)
┌────────┬───────────┬───────┬───────────┐
│ a      ┆ b         ┆ j     ┆ k         │
│ ---    ┆ ---       ┆ ---   ┆ ---       │
│ str    ┆ str       ┆ str   ┆ str       │
╞════════╪═══════════╪═══════╪═══════════╡
│   BCD  ┆ 12431     ┆ BCD   ┆ 12431     │
│ -- 00  ┆ transform ┆ -- 00 ┆ transform │
│  A^^u  ┆ 12__*m    ┆ A^^u  ┆ 12__*m    │
│ -O2    ┆           ┆ -O2   ┆           │
└────────┴───────────┴───────┴───────────┘