I have two excel sheets which I am trying to do data processing.
Sheet A
SN Date(M/D/Y) Values
001 1/1/2021 A
002 1/1/2021 B
003 1/1/2021 C
004 1/1/2021 C
Sheet B
SN Date
001 2/1/2021
002 12/1/2020
003 1/20/2021
The intent is to filter the results of Sheet A using the values from Sheet B. Specifically there are two conditions:
- The SN from Sheet A must exist in Sheet B
- The Date on sheet A must be later then Sheet B for that corresponding SN
therefore the expected results should look like this:
SN Date(M/D/Y) Values
002 1/1/2021 B
Right now I have tried to use this to find it:
value = sheetA.loc[(sheetA['SN'].isin(sheetB['SN'])) & sheetA['Date'] > sheetB['Date']]
However, I am getting ValueError: Can only compare identically-labeled Series objects. How should I go about doing this?