title: Pyspark add sequential and deterministic index to dataframe
body: <p>I need to add an index column to a dataframe with three very simple constraints: </p>
  
  <ul>
  <li><p>start from 0</p></li>
  <li><p>be sequential</p></li>
  <li><p>be deterministic</p></li>
  </ul>
  
  <p>I'm sure I'm missing something obvious because the examples I'm finding look very convoluted for such a simple task, or use non-sequential, non deterministic increasingly monotonic id's. I don't want to zip with index and then have to separate the previously separated columns that are now in a single column because my dataframes are in the terabytes and it just seems unnecessary. I don't need to partition by anything, nor order by anything, and the examples I'm finding do this (using window functions and row_number). All I need is a simple 0 to df.count sequence of integers. What am I missing here?</p>
  
  <p><a href="https://stackoverflow.com/questions/27050247/how-do-i-get-a-sql-row-number-equivalent-for-a-spark-rdd?noredirect=1&amp;lq=1">1</a>, <a href="https://stackoverflow.com/questions/33102727/primary-keys-with-apache-spark">2</a>, <a href="https://stackoverflow.com/questions/46149567/add-sequence-number-column-in-dataframe-usnig-scala">3</a>, <a href="https://stackoverflow.com/questions/37390721/pyspark-row-number-dataframe">4</a>, <a href="https://stackoverflow.com/questions/51200217/how-to-create-sequential-number-column-in-pyspark-dataframe">5</a></p>