【发布时间】:2023-01-11 20:23:45
【问题描述】:
我正在尝试从列值中删除 str 列表,例如:
char_lst = ['1.', '1)', '2.', '2)', '3.', '3)'] # so on with the digit format
我试过了:
import re
df['X'].apply(lambda x: re.sub('|'.join(replace_char), '', re.escape(x))).astype(str)
但它给了我错误:
re.error: unbalanced parenthesis at position 4
【问题讨论】:
标签: python-3.x pandas replace python-re