Advertisement
Guest User

Untitled

a guest
Jun 27th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. ID,Name,Gender
  2. 1,Smith,M
  3. 2,John,M
  4.  
  5. name,gender,city,id
  6.  
  7. name,gender,city,id # name,gender,and id are the only matching columns btw df1 and df2
  8. Smith,M, ,1 # the data copied for name, gender, and id columns
  9. John,M, ,2
  10.  
  11. import pandas as pd
  12.  
  13. f1_df = pd.read_csv("file1.csv")
  14. f2_df = pd.read_csv("file2.csv")
  15.  
  16. for i in f1_df:
  17. for j in f2_df:
  18. i = i.lower()
  19. if i == j:
  20. joined = f1_df.join(f2_df)
  21. print joined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement