我有一个包含三个pandas DataFrames的列表 . 所有DataFrame都具有确切的列名称并具有相同的长度 . 我想比较每个DataFrame中特定列的所有条目 . 假设列表具有:
List=[df1,df2,df3].
每个dataFrame都有以下结构 . df1具有结构
column1 column2 column3
4 3 4
4 5 7
7 6 6
8 6 4
df2具有结构
column1 column2 column3
4 3 4
7 5 7
7 6 5
8 6 4
df3具有结构
column1 column2 column3
4 3 5
4 1 7
7 6 6
8 6 4
我想将df1 column1和column2(对于每一行)的内容与包含df2(column1和column2)和df3(column1和column2)进行比较
我写了一些关于这样的事情:
for i in range(len(List)):# iterate through the list
for j in range(len(List[0].index.values)):# iterate through the the whole dataFrame
#I would like to so something like: if df1[column1][row1]=df2[column1][row1] then do ....
# now i dont know how to iterate through all the dataFrames simulatanously to compare the content of of column 1 and column 2(for each row k) of df1 with the content of column 1 and column 2 of df2 and column 1 and column 2 of df3.
我被困在那里