如何用前三个逗号分隔嵌套列表? Python

How to split a nested list by first three commas? Python

my_df = pd.DataFrame({'ID':['12345','23456','34567'],
     'Info':(['Rob Kardashian', '00052369', '1987-03-17', 'Reality Star'],
                  ['Brooke Barry', '00213658', '2001-03-30', '100','Best','TikTok Star'],
                 ['Stan Lee','35239856','1922-12-28','10','Best Publisher & Producer'])})

我有上面的数据框,我想用前三个逗号拆分 'Info' 列中的值。

下面的代码只适用于所有逗号分割...

[[re.split(',', i) for i in w] for w in my_df['Info']]

预期结果:

像这样简单的东西怎么样?

[[*x[:3], ', '.join(x[3:])] for x in my_df['Info']]

它会return这个输出:

[['Rob Kardashian', '00052369', '1987-03-17', 'Reality Star'], ['Brooke Barry', '00213658', '2001-03-30', '100, Best, TikTok Star'], ['Stan Lee', '35239856', '1922-12-28', '10, Best Publisher & Producer']]