title: Pandas create a unique id for each row based on a condition
body: <p>I've a dataset where one of the column is as below. I'd like to create a new column based on the below condition. </p>
  
  <p>For values in column_name, if 1 is present, create a new id. If 0 is present, also create a new id. But if 1 is repeated in more than 1 continuous rows, then id should be same for all rows. The sample output result can be seen below.</p>
  
  <pre><code>column_name
  1
  0
  0
  1
  1
  1
  1
  0
  0
  1
  
  column_name -- ID
  1 -- 1
  0 -- 2
  0 -- 3
  1 -- 4
  1 -- 4
  1 -- 4
  1 -- 4
  0 -- 5
  0 -- 6
  1 -- 7
  </code></pre>