Issue
I have to find all values in column1 that have transacted in all distinct values in column2. For ex:
From the above table we can identify the Fruitseller 'A' sells all the fruits.
Solution
You can reshape values by crosstab
first and then filter all index values if not 0
by boolean indexing
:
df1 = pd.crosstab(df['Fruitsellers'], df['Fruits'])
out = df1.index[df1.ne(0).all(axis=1)].tolist()
print (out)
['A']
Answered By - jezrael
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.