>>>data_a={'state':[1,1,2],'pop':['a','b','c']}
>>>data_b={'state':[1,2,3],'pop':['b','c','d']}
>>>a=pd.DataFrame(data_a)
>>>a
pop state
0 a 1
1 b 1
2 c 2
>>>b=pd.DataFrame(data_b)
>>>b
pop state
0 b 1
1 c 2
2 d 3
>>>a = a.append(b)
>>>a = a.append(b)
>>>result = a.drop_duplicates(subset=['pop','state'],keep=False)
>>>result
pop state
0 a 1
Python Dataframe ——指定多列去重、求差集
判断 dataframe是否为空:
tmp = readySend_1.append(readySend_2)
tmp = tmp.append(readySend_2)
OverdueData = tmp.drop_duplicates(keep=False)
if not OverdueData.empty:
OverdueData.to_csv('./recommed_need.log', mode='a+', header=False)