There are a lot of examples that all give the same basic example.
dfWithIndex = df.withColumn(\'f_index\', \\ pyspark.sql.functions.lit(1).cast(pyspark.sql.typ