【发布时间】:2017-02-12 15:32:32
【问题描述】:
我有一个熊猫系列:
names = pd.Series([
'Andre Agassi',
'Barry Bonds',
'Christopher Columbus',
'Daniel Defoe',
'Emilio Estevez',
'Fred Flintstone',
'Greta Garbo',
'Humbert Humbert',
'Ivan Ilych'])
看起来像这样:
0 Andre Agassi
1 Barry Bonds
2 Christopher Columbus
3 Daniel Defoe
4 Emilio Estevez
5 Fred Flintstone
6 Greta Garbo
7 Humbert Humbert
8 Ivan Ilych
我想把它变成这样:
0 Agassi, Andre
1 Bonds, Barry
2 Columbus, Christopher
3 Defoe, Daniel
4 Estevez, Emilio
5 Flintstone, Fred
6 Garbo, Greta
7 Humbert, Humbert
8 Ilych, Ivan
有人建议这样的代码,但它没有工作......
names.apply(split)[1]+', ' + names.apply(split)[0]
我检查了以下线程,但它们似乎也不是我想要的:
【问题讨论】: