Код: Выделить всё
import polars as pl
df = pl.DataFrame(
{
"name": [
"some_name_set_1",
"some_name_set_1b",
"some_other_name_set_2",
"yet_another_name_set_2",
]
}
)
df.to_pandas()["name"].str.rsplit("_", n=2, expand=True)
Код: Выделить всё
0 1 2
0 some_name set 1
1 some_name set 1b
2 some_other_name set 2
3 yet_another_name set 2
Подробнее здесь: https://stackoverflow.com/questions/789 ... das-rsplit