How to input data to make desired data list via pyspark
input:
myrdd = List("a1","b1","c1","s2","s5")
Output:
List ((a1,0),(b,1),(c1,2),(s2,3),(s5,4))
Solve:
myrdd = List("a1","b1","c1","s2","s5")
zip = myrdd.zipWithIndex
print(zip)
input:
myrdd = List("a1","b1","c1","s2","s5")
Output:
List ((a1,0),(b,1),(c1,2),(s2,3),(s5,4))
Solve:
myrdd = List("a1","b1","c1","s2","s5")
zip = myrdd.zipWithIndex
print(zip)
Comments
Post a Comment