Here is my example data set:
Name Course Cateory
1: Jason ML PT
2: Jason ML DI
3: Jason ML GT
4: Jason ML SY
5: Jason DS SY
6: Jason DS DI
7: Nancy ML PT
8: Nancy ML SY
9: Nancy DS DI
10: Nancy DS GT
11: James ML SY
12: John DS GT
I want to delete the duplicate rows to have unique rows across the dataframe. Deleting the duplicate rows is based on the values from the column category. The preference for values in the category column are given in this order {'PT','DI','GT','SY'}.
My output dataframe looks like below:
Name Course Cateory
1: Jason ML PT
2: Jason DS DI
3: Nancy ML PT
4: Nancy DS DI
5: James ML SY
6: John DS GT
Currently, I am using a combination of for loop and if condition. Since the Input dataframe is massive (10 Million rows), it takes forever. Is there a better and efficient way to perform the same?