lundi 14 août 2017

How to compare columns in a pandas dataframe

I have a pandas dataframe that looks like this with "Word" as the column header for all the columns:

            Word    Word    Word    Word
         0  Nap     Nap     Nap     Cat
         1  Cat     Cat     Cat     Flower
         2  Peace   Kick    Kick    Go
         3  Phone   Fin     Fin     Nap

How can only return the words that appear in all 4 columns?

Expected Output:

        Word
      0 Nap
      1 Cat

Aucun commentaire:

Enregistrer un commentaire