I'm trying to compare two dataframes:
df1:
entry mass Precursor mass_pos
0 KGTLPK 128 642.780 770.780
1 KGTLPK 48 642.780 690.780
2 KGTLPK 112 642.780 754.780
3 KGTLPK 32 642.780 674.780
4 KGTLPK 156 642.780 798.780
df2:
Mass
0 586.672
1 798.780
2 690.780
3 400.000
My goal is to find any matches of df2 'mass' with df1 'mass_pos'.
I really liked this:
df1['masses match'] = np.where(df2['Mass'] == df1['mass_pos'], 'True', 'False')
But this throws a value error:
ValueError: Can only compare identically-labeled Series objects
I think that this is because these dataframes have a different number of rows. Is there a way to overcome this?