Код: Выделить всё
import polars as pl
s = pl.Series(['{1-5}', '1'])
Код: Выделить всё
# shape: (2,)
# Series: '' [str]
# [
# "{1-5}"
# "1"
# ]
Код: Выделить всё
pl.Series(['{1, 2, 3, 4, 5}', '1'])
Код: Выделить всё
# shape: (2,)
# Series: '' [str]
# [
# "{1, 2, 3, 4, 5}"
# "1"
# ]
Код: Выделить всё
s.str.replace(r'\{(\d+)-(\d+)\}', f'{set(range(1, 6))}')
Код: Выделить всё
s.str.replace(r'\{(\d+)-(\d+)\}', f'{set(range(int('${1}'), int('${2}' + 1)))}')
Подробнее здесь: https://stackoverflow.com/questions/784 ... str-replac
Мобильная версия