Here is a pandas dataframe:
dt name type City
05-10-2021 MK [PQRRC, MNXYZ, AYPIC, KLUYT, GFTBE, BYPAC] NYC
05-10-2021 MK [GFTBE, AYPIC, MNXYZ, BYPAC, KLUYT, PQRRC] NYC
05-12-2021 MK [KLUYT, PQRRC, BYPAC, AYPIC, GFTBE, MNXYZ] NYC
05-12-2021 MK [BYPAC, KLUYT, GFTBE, AYPIC, MNXYZ, PQRRC] NYC
05-13-2021 PS [XYDFE, QRTSL, CPQLE, VXWUT, ORSHC, LTRDX] BAL
05-13-2021 PS [VXWUT, ORSHC, QRTSL, XYDFE, LTRDX, CPQLE] BAL
.... Please note that the list of values in column type for each column name is the same but not sorted in alphabetical order.
I want the output as below: sort the column type and find the distinct dt, name, type, City.
dt name type City
05-10-2021 MK [AYPIC, BYPAC, GFTBE, KLUYT, MNXYZ, PQRRC] NYC
05-12-2021 MK [AYPIC, BYPAC, GFTBE, KLUYT, MNXYZ, PQRRC] NYC
05-13-2021 PS [CPQLE, LTRDX, ORSHC, QRTSL, VXWUT, XYDFE] BAL
I tried using sort_values, sorted, drop_duplicates; not working. May be I made some mistakes. Its dropping some names altogether, meaning missing some names when using drop_duplicates(). Can someone help me? Thank you.
AYPICtypealso ? Seems need to, right ?