1

I have an Excel file that consists of two columns: last_name, first_name. The list is sorted by years of experience. I would like to create an new Excel file (or text file) that prints the names two-by-two.

Last       First
Smith      Joe
Jones      Mary
Johnson    Ken 
etc

and converts it to

Smith      Joe           Jones       Mary
Johnson    Ken           etc.

effectively printing every other name on the same row as the name above.

I have reached the point where the names can be printed into a single set of columns, but I can't move every other name to adjacent columns.

Thanks

ThePyGuy
  • 17,779
  • 5
  • 18
  • 45
James Dull
  • 21
  • 1

1 Answers1

1

TRY:

result = pd.concat([df.iloc[::2].reset_index(drop=True),
           df.iloc[1::2].reset_index(drop=True)], 1)

OUTPUT:

      Last First   Last First
0    Smith   Joe  Jones  Mary
1  Johnson   Ken    etc  None
Nk03
  • 14,699
  • 2
  • 8
  • 22