【发布时间】:2016-10-21 14:04:27
【问题描述】:
我的df 有 2 列:
Name Attr
a(bc)
b(aca)
(cba)
我希望列 Attr 的值包含在列 Name 的括号内
Name Attr
a(bc) bc
b(aca) aca
(cba) cba
我试过了:
df['Attr'] = re.findall('\(.*?\)',df['Name'].astype('str'))
TypeError: expected string or buffer
非常感谢任何帮助
【问题讨论】:
标签: python regex pandas dataframe parentheses