0
I have a question and would like your help. I have two Dataframe and I need to compare some columns of these Dataframe are equal and, if they are equal, then I need to store the records in another Dataframe. I mean, I need to create a new Dataframe from the comparison of other two. The example refers to df1 and df2 (need to compare 4 criteria - 'x', y', z', w') and after the comparison create the dfNovo with the records that were true in the comparison. In the case of the example below, the dfNovo would be formed by the record of df1 index 0 and by the record of df2, since they are equal in the criteria mentioned.
import pandas as pd
df1 = pd.DataFrame({"x": ['f','m','f'],
"y": [11,22,39],
"z": ['C','nC','nC'],
"w": ['F','S','M'],
"var1":["no", "yes", "no"],
"var2":["yes", "yes", "yes"],
"var3":["no", "no", "no"],
"classe":["yes", "yes", "no"]})
df2 = pd.DataFrame({"x": ['f','f','m'],
"y": [11,22,40],
"z": ['C','C','nC'],
"w": ['F','M','M'],
"var1":["yes", "yes", "no"],
"var2":["no", "no", "yes"],
"var3":["no", "no", "yes"],
"classe":["no", "yes", "yes"]})