输入数据框
data = {
'G_ID': ['s1','s2','s3','s4','s5','s6','s7','s8','s9'],
'id' : [753,753,753,700,700,700,581,800,800,],
's_id': [ 753,751,752,700,700,700,581,800,800]
}
df = pd.DataFrame.from_dict(data)
print (df)
G_ID id s_id
0 s1 753 753
1 s2 753 751
2 s3 753 752
3 s4 700 700
4 s5 700 700
5 s6 700 700
6 s7 581 581
7 s8 800 800
8 s9 800 800
预期产量
G_ID id s_id diff
s2 753 751 Y
s3 753 752 Y
尝试比较数据帧中两个列的值id和S_id(如果值不同),请获取数据帧的子集。