3

I'm wondering how to merge multiple CSV files using Pandas, but using two specific criteria:

  • I don't want values to be merged if they have a common key. As in, I don't want data to be merged as it would via a SQL Join. I want all raw data to show as it does in the original CSV file
  • I want the CSV file values to be merged as new columns, and not as it does in the append function, where it puts the values underneath the first grouping

For example:

CSV File 1
Column A Column B Column C 100 200 300

CSV File 2
Column A Column B Column C 400 500 600

Desired Output
Column A Column B Column C Column A Column B Column C 100 200 300 400 500 600

1 Answer 1

2

You can concatenate them column-wise by passing param axis=1:

In [26]:

pd.concat([df,df1],axis=1)
Out[26]:
   Column A  Column B  Column C  Column A  Column B  Column C
0       100       200       300       400       500       600
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.