2017-03-16 136 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()