title: Checking and deleting duplicate neighbor values in a series of rows for a DataFrame
body: <p>I have a set of rows in a dataframe that have some duplicate neighboring values which are all located in <strong>the same position of each column</strong> and looks like this:</p>
  
  <pre><code>row_data = pd.DataFrame({0 : [1.1, 1.2, 1.2, 1.3, 1.4, 1.5, 1.5, 1.6],
  1 : [2.3, 2.2, 2.2, 2.3, 2.4, 2.5, 2.5, 2.6],
  2 : [2.4, 2.2, 2.2, 2.3, 2.4, 2.6, 2.6, 2.7],
  3 : [7.1, 7.2, 7.2, 7.3, 7.4, 7.5, 7.5, 7.6]}).T
  </code></pre>
  
  <p>As stated above the (1.2, 1.2) in row 0 is in the same position as (2.2, 2.2) in row 1, (2.2, 2.2) in row 2, and (7.2, 7.2) in row 3, etc...</p>
  
  <p>I want to be able to first check if there are <strong>duplicate neighbors</strong> within every row, remove the duplicates <strong>leaving only the first instance of it</strong>, and give me a count of how many <strong>total</strong> duplicates were removed.</p>
  
  <p>I've tried iterating over each row but that is much too time intensive as this dataframe is very large (36 rows by 260,000 columns). The pseudo code I'd like to have would follow this logic:</p>
  
  <pre><code>count_dup = 0
  for index in range(0, len(row_data.columns)):
      if row_data[index] == row_data[index+1]:
           count_dup = count_dup + 1
           row_data[index] = np.nan
  </code></pre>
  
  <p>My pseudo code obviously does not work but the rest would be to remove the NANs by dropping the duplicates off all columns.</p>
  
  <p>The output would be:</p>
  
  <pre><code>row_data_dropped = pd.DataFrame({0 : [1.1, 1.2, 1.3, 1.4, 1.5, 1.6],
  1 : [2.3, 2.2, 2.3, 2.4, 2.5, 2.6],
  2 : [2.4, 2.2, 2.3, 2.4, 2.6, 2.7],
  3 : [7.1, 7.2, 7.3, 7.4, 7.5, 7.6]}).T
  
  total_dropped_neighbors = 8
  </code></pre>
  
  <p>Is there any way I can do this?</p>