title: Create a dummy column based on a different column
body: <p>I have panel data and want to create a column &quot;active trader&quot; for each ID for each period, if the ID has at least traded once per quarter consecutively</p>
  <p>current df</p>
  <pre><code>ID  date   trading   
  A   2020Q1 4         
  A   2020Q2 5         
  A   2020Q3 0         
  A   2020Q4 2         
  A   2021Q1 1         
  B   2019Q1 0         
  B   2019Q2 1         
  B   2019Q3 2         
  C   2021Q1 3         
  C   2021Q2 3         
  C   2021Q3 4         
  C   2021Q4 0         
  ...
  </code></pre>
  <p>desired</p>
  <pre><code>ID  date   trading   active
  A   2020Q1 4         1
  A   2020Q2 5         1
  A   2020Q3 0         0
  A   2020Q4 2         0
  A   2021Q1 1         0
  B   2019Q1 0         0
  B   2019Q2 1         0
  B   2019Q3 2         0
  C   2021Q1 3         1
  C   2021Q2 3         1
  C   2021Q3 4         1
  C   2021Q4 0         0
  ...
  </code></pre>