python - Merging two CSV files on common column - result: empty -
i have 2 csv files:
- filmdata: userid, age of user, filmid, sex of user
- filmnames: filmid (which common column) , filmname
i merge 2 files, have 1 csv file userid, age, filmid, sex , filmname (based on filmid).
i using following code snippet:
import pandas pd = pd.read_csv("c:/users/alex/box sync/cs109/predictions/filmdaten.csv.csv") b = pd.read_csv("c:/users/alex/box sync/cs109/predictions/filmnamenneu.csv.csv") b = b.dropna(axis=1) merged = a.merge(b, on='filmid') merged.to_csv("c:/users/alex/box sync/cs109/predictions/filmoutput.csv", index=false)
filmdaten.csv
looks this:
userid,alter,geschlecht,beruf,plz,filmid,bewertung 1,24,m,technician,85711,61,4 1,24,m,technician,85711,189,3
filmnamenneu.csv
this:
filmid, filmnamen 1, toy story 2, jurassic parc
when column names indeed merge, filmname
column in output file remains empty. know solution?
Comments
Post a Comment