This is a step by step tutorial on how to use Spark zipWithIndex method to add index to a Spark dataframe. This video explains how you can read a csv file as a dataframe, convert the dataframe to rdd and apply a map method to convert each record to array which is then converted to a dataframe with additional column, the index column.