Use issubset to compare set values between two pandas dataframe columns
4
I have a pandas dataframe with two columns that are filled with pandas sets. I want to check that all values in one column are a subset of the other column. I thought the code below would work but it seems you cannot apply .issubset() to two series with sets. Ex: data = [[['one','orange','green'],['one','orange']],[['milk','honey'],['Clarke', 'honey']]] df = pd.DataFrame(data, columns=['Column_1','Column_2']) Are_all_column_2_values_valid = df.loc[:, 'Column_2'].apply(set).issubset(df.loc[:, 'Column_1']) desired_output = pd.series([True,False]) All values in both sets will be strings. Any help would greatly be appreciated!
python python-3.x pandas ...