0

I am concenating five dataframes to a single dataframe and then saving that dataframe as an xlsx file. However, the individual dataframes do not align properly. Lets assume that the first dataframe ends at row 700 and the second one begins at 701. This is what it looks like in the xlsx file(placeholder column elements):

Index    Name      Code    Email    Name(duplicate)
 699      Austin    abc    mail1
 700      Kate      def    mail2
 701                hjk    mail3      Stacy

As you can see, when moves on to the data from the second dataframe, the columns shift. Individual dataframes have the same column titles and the same number of columns in the same order. But when they are concanated vertically, all columns starting from the second dataframe shift one column, with the names now being at the last duplicate column, instead of in their proper place. This only happens when going from first dataframe to the second. When going from second to third for example, it continues to use the fake name column instead of the real one. The code I used is given below.

toplam=pd.concat([anapa_1,anapa_2,anapa_3,anapa_5,anapa_6],verify_integrity=True,ignore_index=True)

The anapas are the original dataframes. They are completely normal when saved seperately, they only behave this way when they are put together. It is very important that all elements stay in their respective columns at all times. Any help would be appreciated.

Snowlarks
  • 13
  • 2
  • It's hard to help you based on the information you've given. You should post some code that people can copy/paste/run, so they'll reproduce your issue, instead of trying to describe it textually. Also, you need to give us some data to work on. Have a look at [this link](https://stackoverflow.com/help/minimal-reproducible-example) and [this one](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) to help you improve your question and get more answers. – joao Mar 06 '21 at 12:51
  • I tried again with another dataframe set with identical specs but this situation did not happen. I guess it was just a fluke then, I found a workaround anyways. Thank you. – Snowlarks Mar 06 '21 at 17:09

0 Answers0