Python Forum

Full Version: How to find common names in multiple columns
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I have below data frame, and I want get the common values in all three columns.

1 2  3
2 5  45
5 8  4
4 0  5 
6 10 11 
9 4  0

Desired output:
2
5
4
What have you tried? How is it not working?
Set intersection?

But you need to more clearly define your input => output first. If 2 is valid output, why isn't 0? 2 isn't in all three columns, so if you want values that match at least two columns, then 0 would also match. Unless there's another criteria you haven't mentioned.
(Nov-27-2018, 06:22 PM)nilamo Wrote: [ -> ]so if you want values that match at least two columns, then 0 would also match.

I thought it was the most common values across all three columns, but it is still the same question. Two occurs twice and so does zero.