I've got a dataframe like this
Sample_ID Main_Sample_ID
1ABC [2052, 2402]
2CBA [228]
and an external list with allowed values:
allowed = [2402]
What I'm trying to do is filtering those rows which have allowed values and deleting those which don't, deleting either the internal list values that are not allowed too.
At the end, I'd like to get the result:
Sample_ID Main_Sample_ID
1ABC [2402]
I tried it with:
sample_type_ids_list = self._full_structure['Main_Sample_ID'].tolist()
for sample_type_ids in sample_type_ids_list:
for sample_type_id in sample_type_ids:
info_by_type_df['flag'] = info_by_type_df.apply(lambda x: int(sample_type_id in allowed), axis=1)
I also tried with .loc and .isin() but without success...
Could you help me? Thanks in advance!