Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 通过比较两个数据帧获得唯一的行_Python_Pandas_Dataframe - Fatal编程技术网

Python 通过比较两个数据帧获得唯一的行

Python 通过比较两个数据帧获得唯一的行,python,pandas,dataframe,Python,Pandas,Dataframe,有两个df df1 df2 预期产出: 从数据帧中获取唯一行比较,并在df1中显示唯一列 df1 你可以试试下面的方法 df1[(~df1['0'].isin(df2['0'])) & (~df1['1'].isin(df2['1']))] 你可以试试下面的方法 df1[(~df1['0'].isin(df2['0'])) & (~df1['1'].isin(df2['1']))] 您尝试过什么吗?您所说的“在df1中显示唯一列”是什么意思df1只有一列。已尝试合并,但当df

有两个df

df1

df2

预期产出:

从数据帧中获取唯一行比较,并在df1中显示唯一列

df1

你可以试试下面的方法

df1[(~df1['0'].isin(df2['0'])) & (~df1['1'].isin(df2['1']))]
你可以试试下面的方法

df1[(~df1['0'].isin(df2['0'])) & (~df1['1'].isin(df2['1']))]

您尝试过什么吗?您所说的“在
df1
中显示唯一列”是什么意思
df1
只有一列。已尝试合并,但当df1的某些行与DF2匹配时,我需要从df1中删除这些行。这是否回答了您的问题?您尝试过什么吗?您所说的“在
df1
中显示唯一列”是什么意思
df1
只有一列。已尝试合并,但当df1的某些行与DF2匹配时,我需要从df1中删除这些行。这是否回答了您的问题?
0       1
7916   stuart 
df1[(~df1['0'].isin(df2['0'])) & (~df1['1'].isin(df2['1']))]
      0     1
3   7916    stuart