I have a pandas series:
names = pd.Series([
'Andre Agassi',
'Barry Bonds',
'Christopher Columbus',
'Daniel Defoe',
'Emilio Estevez',
'Fred Flintstone',
'Greta Garbo',
'Humbert Humbert',
'Ivan Ilych'])
Which looks like this:
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
and I want to make it like this:
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
Someone suggested code like this, but it didn't work...
names.apply(split)[1]+', ' + names.apply(split)[0]
I checked the following threads, but they didn't seem to be what I wanted either: