python中的Split()如果有条件必须跳过某个值,如何使用

python中的Split()如果有条件必须跳过某个值,如何使用,python,pandas,split,Python,Pandas,Split,我是python新手,我想将包含电影名称和发行年份的一列数据分离到多列,所以我找到了split函数 数据按标题(年份)组织 我在python中尝试的是: movies['title'].str.split('(', 1, expand = True) 以下情况例外: 《迷失儿童之城》(洛杉矶佩杜斯儿童城)(1999年) 迷路儿童之城。洛杉矶佩杜斯儿童城(1999年) 我所期待的只是1999年)进入第二栏 我需要你的帮助 我投票赞成在这里使用re.findall和模式(.*)\(\d{4}):

我是python新手,我想将包含电影名称和发行年份的一列数据分离到多列,所以我找到了split函数

数据按标题(年份)组织

我在python中尝试的是:

movies['title'].str.split('(', 1, expand = True)
以下情况例外:

《迷失儿童之城》(洛杉矶佩杜斯儿童城)(1999年)

迷路儿童之城。洛杉矶佩杜斯儿童城(1999年)

我所期待的只是1999年)进入第二栏


我需要你的帮助

我投票赞成在这里使用
re.findall
和模式
(.*)\(\d{4})

这张照片是:

[('City of Lost Children, The (Cité des enfants perdus, La)', '1999'),
 ('City of Lost Children, The. Cité des enfants perdus, La)', '1999')]

我投票赞成在这里使用
re.findall
和模式
(.*)\(\d{4})

这张照片是:

[('City of Lost Children, The (Cité des enfants perdus, La)', '1999'),
 ('City of Lost Children, The. Cité des enfants perdus, La)', '1999')]

我建议
pd.Series.str.rsplit

给定一系列
s

print(s)
0    City of Lost Children, The (Cité des enfants perdus, La) (1999)
1    'City of Lost Children, The. Cité des enfants perdus, La) (1999)'
dtype: object
使用
s.str.rsplit('(',1,expand=True)


我建议
pd.Series.str.rsplit

给定一系列
s

print(s)
0    City of Lost Children, The (Cité des enfants perdus, La) (1999)
1    'City of Lost Children, The. Cité des enfants perdus, La) (1999)'
dtype: object
使用
s.str.rsplit('(',1,expand=True)


请共享数据帧的示例和预期的输出可能的副本。请共享数据帧的示例和预期的输出可能的副本!可能对于pandas
df.title.str.findall(r'(.*?)\(\d{4})\)
Neat!可能对于pandas
df.title.str.findall(r'(.*?)\(\d{4})\)\)