【发布时间】:2023-04-10 10:55:01
【问题描述】:
在 python 中,我有以下 df(第一行的标题):
FullName FirstName
'MichaelJordan' 'Michael'
'KobeBryant' 'Kobe'
'LeBronJames' 'LeBron'
我正在尝试根据“FirstName”中的值拆分“FullName”中的每条记录,但我没有运气......
这是我尝试过的:
df['Names'] = df['FullName'].str.split(df['FirstName'])
这会产生错误:
'Series' objects are mutable, thus they cannot be hashed
期望的输出:
print(df['Names'])
['Michael', 'Jordan']
['Kobe', 'Bryant']
['LeBron', 'James']
【问题讨论】:
-
您可以发布您想要的所需示例输出吗?