mardi 1 juillet 2014

Difference between pandas DataFrames by certain columns


Vote count:

0




I am looking for a way to identify a subset of rows from one DataFrame that are not present in another DataFrame, when compared by only a few columns.


For example,



df1 = DataFrame([dict(id1=1, id2='ABC', val=23.45), dict(id1=2, id2='MNO', val=21.23)])
df2 = DataFrame([dict(id1=1, id2='ABC', val=42.45)])

# pseudo code
diff_df = df1 - df2 # compare only by id1 & id2, as a pair
>>> diff_df
id1 id2 val
1 2 MNO 21.23


asked 23 secs ago

y2p

1,033





Aucun commentaire:

Enregistrer un commentaire