I have two pyspark dataframes - Dataframe A
+----+---+
|name| id|
+----+---+
| a| 3|
| b| 5|
| c| 7|
+----+---+
Dataframe B
+----+---+
|name| id|
+----+---+
| a| 3|
| b| 10|
| c| 13|
+----+---+
I want to subtract dataframe B from Dataframe A based on column id. So the result dataframe should be -
+----+---+
|name| id|
+----+---+
| b| 5|
| c| 7|
+----+---+
This is my code,
common = A.join(B, ['id'], 'leftsemi')
diff = A.subtract(common)
diff.show()
But it does not give expected result. Is there a simple way to achieve this which can subtract on dataframe from another based on one column value. Unable to find it. Thanks in advance