I have a pandas DataFrame
Company Name | Person Name | Phone number
General Electric | John Doe |
Ford | | 123 456 789
I want to fill empty names with the company name
Company Name | Person Name | Phone number
General Electric | John Doe |
Ford | Ford | 123 456 789
I could write
df.loc[df["Person Name"].isna(),'Person Name'] = df["Company Name"]
but it would modify the original DataFrame.
df.copy().loc[df["Person Name"].isna(),'Person Name'] = df["Company Name"] should do the trick, but is there a more elegant way to do it, without using copy() ?