Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ID,Name,Gender
- 1,Smith,M
- 2,John,M
- name,gender,city,id
- name,gender,city,id # name,gender,and id are the only matching columns btw df1 and df2
- Smith,M, ,1 # the data copied for name, gender, and id columns
- John,M, ,2
- import pandas as pd
- f1_df = pd.read_csv("file1.csv")
- f2_df = pd.read_csv("file2.csv")
- for i in f1_df:
- for j in f2_df:
- i = i.lower()
- if i == j:
- joined = f1_df.join(f2_df)
- print joined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement