2017-03-16 212 views
1
聯盟

比方說,我有兩個dataframes:減去兩個數據幀

第一個是大名單(2400+值):

101 102 103 104 [index value] 
"A" "B" "C" "D" [another string] 
"1" "1" "1" "1" [another string] 
"2" "2" "2" "2" [another string] 

,然後不合格值的第二數據幀,我想從第一個數據集刪除,但可能有未包含在第一數據幀中的一些值:

101 104 205 [index value] 
"A" "D" "Q" [another string] 
"1" "1" "2" [another string] 
"2" "2" "1" [another string] 

我怎麼會拿這兩個聯盟(那些匹配)和祛瘀他們從第一個數據幀?在這個例子中,我將要結束了:

102 103 [index value] 
"B" "C" [another string] 
"1" "1" [another string] 
"2" "2" [another string] 
+0

根據你的描述,你不應該結束第102和103列嗎? – feedMe

+0

@feedMe是的,對不起,讓我糾正一下。 –

回答

0

假設你有一定的index_column一個DF含有該指數,並具有類似名稱的列被取消資格(DSQ)數據幀:

dsq = df_dsq['index_column'].to_list() 
df_clean= df.loc[~df['index column'].isin(dsq), :].copy()