Вы можете попробовать .apply
def name_parsing(name):
"This function parses the name anyway you want"""
return HumanName(name)['title']
# with .apply, the function will be applied to every item in the column
# the return will be a series. In this case, the series will be attributed to 'title' column
data['title'] = data['name'].apply(name_parsing)
Кроме того, другой вариант, который мы обсуждаем ниже, заключается в сохранении экземпляра HumanName
в кадре данных, поэтому, если вам понадобится другая информация из него позже, вам не нужно создавать экземпляр и анализировать имя снова ( Работа с строками может быть очень медленной на больших фреймах данных).
Если это так, частью решения будет создание нового столбца. После этого из него вы получите атрибут ['title']:
# this line creates a HumanName instance column
data['HumanName'] = data['name'].apply(lambda x: HumanName(x))
# this lines gets the 'title' from the HumanName object and applies to a 'title' column
data['title'] = data['HumanName'].apply(lambda x: x['title'])