I have a dataframe column of first and last names. I want to extract the initials from the names as another column in my dataframe. For the following dataframe:
Name 0 'Brad Pitt' 1 'Bill Gates' 2 'Elon Musk'
I have came up with a solution:
df['initials'] = [df['Name'][i].split() + df['Name'][i].split() for i in range(len(df))]
However, for a name such as ‘John David Smith’, this does not work, as I want to have the first letter of each word in a name. Moreover, since my dataframe is quite large, I would like to know if there is a ‘vectorized’ solution (without
Thank you in advance.
This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.