Untitled

 avatar
unknown
plain_text
a year ago
783 B
2
Indexable
merged_df['Column6'] = merged_df.apply(lambda row: ', '.join(set(str(row['Column3']).split(', ')) - set(str(row['Column4']).split(', '))) if row['Column3'] and row['Column4'] and not pd.isnull(row['Column3']) and not pd.isnull(row['Column4']) else '', axis=1)
merged_df['Column7'] = merged_df.apply(lambda row: ', '.join(set(str(row['Column4']).split(', ')) - set(str(row['Column3']).split(', '))) if row['Column3'] and row['Column4'] and not pd.isnull(row['Column3']) and not pd.isnull(row['Column4']) else '', axis=1)
merged_df['Column8'] = merged_df.apply(lambda row: ', '.join(set(str(row['Column3']).split(', ')) & set(str(row['Column4']).split(', '))) if row['Column3'] and row['Column4'] and not pd.isnull(row['Column3']) and not pd.isnull(row['Column4']) else '', axis=1)
Leave a Comment