I have 2 files. In one file1 I have 998 records and in another file2, I have 1000 records. Now, when I try df1.subtract(df2) it gives 998 records and when I try df2.subtract(df1) it gives 1000 as the count. I also compared it manually in excel. All the records are same the except the additional records in file2. So, the expected output for df2.subtract(df1) should be 2. Where am I going wrong? Is there any way to match two data frames irrespective of its rows order?
df1:
First Approach:
df1 = spark.read.option("header","true").csv("Sales_records-1.csv")
df2 = spark.read.option("header","true").csv("Sales_records-2.csv")
#Finding the rows which are not present in second dataframe
df3 = df2.exceptAll(df1)

