0

I need to merge name and surname from two columns and add this as a new column. I can do it but once its done I lost 16K rows and this new column with full name should be applied to all rows I have in the file.

Anyone knows why this might happen?

This is the code I used to create additional column:

FullName = Trainings['First Name']+" "+Trainings['Last Name']
Trainings.insert(5, 'Full Name', FullName, True)

After that I lost the data and this new column was applied to 5 rows.

Ynjxsjmh
  • 28,441
  • 6
  • 34
  • 52
  • 2
    if you don't share the relevant part of your code then no one can see what you are doing wrong – Anentropic Aug 16 '22 at 09:44
  • Please, read this https://stackoverflow.com/help/minimal-reproducible-example and this https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples and edit your question accordingly. It is not possible for us to help you otherwise. – alec_djinn Aug 16 '22 at 13:51

1 Answers1

0

The way to do it:

df['fullname'] = df['first'] + df['last']

Taking into account that these are your column names. This way no data should be lost

gtomer
  • 5,643
  • 1
  • 10
  • 21