title: Pandas Dataframe: how can i compare values in two columns of a row are equal to the ones in the same columns of a subsequent row?
body: <p>Let's say I have a dataframe like this</p>
  <pre><code>Fruit  Color  Weight
  apple   red    50
  apple   red    75
  apple  green   45
  orange orange  80
  orange orange  90
  orange  red    90
  </code></pre>
  <p>I would like to add a column with True or False according to the fact that Fruit and Color of row x are equal to Fruit and Color of row x+1, like this:</p>
  <pre><code>Fruit  Color  Weight Validity
  apple   red    50      True
  apple   red    75      False
  apple  green   45      False
  orange orange  80      True
  orange orange  90      False
  orange  red    90      False
  </code></pre>
  <p>I have tried the following, but there are some errors I guess, I am getting wrong results:</p>
  <pre><code>g['Validity'] = (g[['Fruit', 'Color']] == g[['Fruit', 'Color']].shift()).any(axis=1) 
  
  </code></pre>