0

I have a sample data frame with the following format.

 First name Middle name Last name
1   Andy        Brad        None
2   Alex        Cian        None
3   Brad        Edward      None
4   Brad        Dan         Craig
5   Liam        Chat        Meny

In a data frame, how do I get the last name where a name is provided (Craig, Meny) to replace the name in 'Middle Name' column whilst all the rest stays the same.

Output required

  First name    Last name
1   Andy        Brad
2   Alex        Cian
3   Brad        Edward
4   Brad        Craig
5   Liam        Meny
anky
  • 74,114
  • 11
  • 41
  • 70
Alex
  • 1
  • 3
  • 1
    you can use fillna on the last name : `df['Last name'] = df['Last name'].fillna(df['Middle name'])` – anky Apr 12 '20 at 13:04
  • Thank you. This solution solved the issue. The links to the other solutions above were not helpful in this instance so it is important to keep the question open. Thanks again! – Alex Apr 12 '20 at 13:35

0 Answers0