Код: Выделить всё
import polars as pl
import polars.selectors as cs
data_frame = pl.DataFrame({'a': ['a', 'b', 'c'], 'b': range(3), 'c': [.1, .2, .3]})
non_string_columns = [col for col in data_frame.columns if data_frame[col].dtype != pl.String]
for col in non_string_columns:
data_frame = data_frame.with_columns(pl.col(col).cast(pl.String))
Код: Выделить всё
data_frame.with_columns(~cs.string().as_expr().cast(pl.String))
Как можно преобразовать сразу несколько столбцов в строку (используя полярный параллелизм) с помощью селектора cs?>
Подробнее здесь: https://stackoverflow.com/questions/775 ... -to-string
Мобильная версия