Start index with certain value zipWithIndex in pyspark

六月ゝ 毕业季﹏ 提交于 2021-01-29 17:17:04

问题


I want to start value of indexes in data frame with certain value instead of default value zero, if there is any parameter we can use for zipWithIndex() in pyspark.


回答1:


the following solution will help to start zipwithIndex with default value.

df = df_child.rdd.zipWithIndex().map(lambda x: (x[0], x[1] + index)).toDF()

where index is default number you want to start with zipWithIndex.



来源:https://stackoverflow.com/questions/60124599/start-index-with-certain-value-zipwithindex-in-pyspark

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!