Last active
August 18, 2020 09:12
-
-
Save mahpah/d201287950b27810d8eac8fc9191da4b to your computer and use it in GitHub Desktop.
compare using pandas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
path = r'/home/mahpah/repo/labs/python/data/input.xlsx' | |
data = pd.read_excel(path) | |
data = data.sort_values(by = ['ID', 'Ngay']) | |
data.loc[data['No qua han'].eq(data['No qua han'].shift()), 'match'] = 'no change' | |
data.loc[data['No qua han'].lt(data['No qua han'].shift()), 'match'] = 'A' | |
data.loc[data['No qua han'].gt(data['No qua han'].shift()), 'match'] = 'B' | |
data.loc[data['ID'].ne(data['ID'].shift()), 'match'] = '' | |
print(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment