Reputation: 649
I want to get all unique values from one column, and see if each unique value have the same values in another column. below I have a data frame and I am looking for unique values in the first column {2,3,4}
. And I am trying to see if these values have unique values in same position in the last column.
By looking, clearly only 3
values in the first column has only the same values (4
) in corresponding position in the last column . So (3, 4)
matches. How could I achieve this paring (3, 4)
in Pandas
? Unique values in column 1 must only have unique values in column 4!
2 2 1 4
2 3 4 4
3 4 3 4
3 5 8 4
2 6 9 2
4 1 6 2
4 4 1 4
2 4 5 2
Upvotes: 0
Views: 126
Reputation: 323226
I do not quit clear the question , since column1 have match 2 and 4 with column 4 . thanks Igor's comment.
df.groupby('c1').c4.unique().loc[lambda x : x.str.len()==1].str[0]
Out[116]:
c1
3 4
Name: c4, dtype: int64
Upvotes: 1