0
concat = pd.concat([data_1, data_2])

above code works on multiple CSVs but it duplicates the column tried reset_index and axis=0 but no good.

all CSVs have 21 columns but the code gives me 42 columns after concat

Any suggestions, ideas, comments are much appreciated.

Thanks

Panda
  • 23
  • 7
  • Are you wanting concatenate horizontally or vertically? What is this duplicated column? What does `data_1` and `data_2` look like? – Riley Oct 27 '21 at 07:59
  • 1
    Does this answer your question? [Concatenate rows of two dataframes in pandas](https://stackoverflow.com/questions/28135436/concatenate-rows-of-two-dataframes-in-pandas) – kd88 Oct 27 '21 at 08:05
  • all CSVs have 21 columns but the code gives me 42 columns after concat – Panda Oct 27 '21 at 08:30

2 Answers2

0

Have you tried using axis=1 . It will concatenate column wise.

concat = pd.concat([data_1, data_2], axis =1)
Talal Siddiqui
  • 106
  • 1
  • 7
-2

Convert them to numpy array and then concat using hstack and vstack