title: How to Find the consecutive values in Pandas DataFrame column and replace the value
body: <p>I have a below Dataframe</p>
  <pre><code>Col1    Col2    Col3
  A       ABC     100
  B       BCD     200
  C       CDA     300
  D       CDA     400
  E       CDA     500
  F       EFG     600
  G       XYZ     700
  H       XYZ     800
  I       PQR     900
  </code></pre>
  <p>We can see that in Col2 CDA is repeated 3 times and XYZ is repeated 2 times.</p>
  <p>Now I need create the new column <strong>NewCol4</strong> and check for the consecutive values, if there are consecutive values just add <strong>underscore at the last and add the number after underscore</strong>, if it is not consecutive value leave as it is.</p>
  <p>I need the output in the below format.</p>
  <pre><code>Col1    Col2    Col3   NewCol4
  A       ABC     100    ABC
  B       BCD     200    BCD
  C       CDA     300    CDA_1
  D       CDA     400    CDA_2
  E       CDA     500    CDA_3
  F       EFG     600    EFG
  G       XYZ     700    XYZ_1
  H       XYZ     800    XYZ_2
  I       PQR     900    PQR
  </code></pre>
  <p>I am very new to Pandas, is there any way to achieve the above output that it would be really helpful.</p>