Contemplating a few options to understand which one would be the best for the below scenario:
I have a dataframe in pandas that looks something like
CODE NAME COL1 COL2 COL3
IN INDIA x x z
US USA r s s
IND INDIA f d d
RU RUSSIA g f d
USA USA d s s
IN INDIA d d a
I would like to create a new column, say POSSIBLE_CODES such that it is a list of all the CODES the corresponding NAME column has see. So my target df should look like:
CODE NAME COL1 COL2 COL3 POSSIBLE_CODES
IN INDIA x x z [IN, IND]
US USA r s s [US, USA]
IND INDIA f d d [IN, IND]
RU RUSSIA g f d [RU]
USA USA d s s [US, USA]
IN INDIA d d a [IN, IND]