I'm trying to compare two dataframes, and then delete the matches from both.
I figured tempSheet = tempSheet[tempSheet != testdf]
would work, but I get an error saying
ValueError: Can only compared identically-labeled DataFrame objects
The column names are the same, so I'm guessing it's just impossible to do it that way.
Is there an obvious syntax error I have? Is there a way to use pd.merge
to return the ones that are not matched?
My dataframes look like this:
Qty Price
0 1 1.30
1 6 2.70
2 8 0.20
3 10 3.90
4 9 11.25
5 15 1.89
6 26 2.67
7 200 7.65
...
Qty Price
0 1 1.30
1 10 3.90
2 15 1.89
3 16 0.98
4 2 10.52
5 66 9.87
6 9 13.42
7 43 27.65
...
I want to cut the first down to only the matches, so
Qty Price
0 6 2.70
1 8 0.20
2 9 11.25
3 26 2.67
...
I would then do the same thing to the second.