Spark Dataframe :How to add a index Column : Aka Distributed Data Index

后端 未结 7 2244
我寻月下人不归
我寻月下人不归 2020-11-27 18:49

I read data from a csv file ,but don\'t have index.

I want to add a column from 1 to row\'s number.

What should I do,Thanks (scala)

7条回答
  •  情话喂你
    2020-11-27 19:08

    For SparkR:

    (Assuming sdf is some sort of spark data frame)

    sdf<- withColumn(sdf, "row_id", SparkR:::monotonically_increasing_id())

提交回复
热议问题