JackG
JackG

Reputation: 27

Combine CSV files with columns out of order

I have 5 CSV files that I need to combine into one. Each has 5 columns of the same names but in one of them the 3rd and 4th column are reversed. What is the best way to go about merging these files?

Upvotes: 1

Views: 414

Answers (1)

Rhubarb
Rhubarb

Reputation: 308

import pandas as pd

csv1 = pd.read_csv("/path/to/csv1.csv")
csv2 = pd.read_csv("/path/to/csv2/csv")

final_csv = pd.concat([csv1, csv2])
final_csv.to_csv("/path/to/final_csv.csv")

Upvotes: 2

Related Questions