Please does anyone knows what is the error in this line of code? Spend hours searching but didn't succeed to fix it. Thank youu in advance,
labels = RDD.map(lambda (a, b): a).collect()
Syntax error
If you are using python 3 probably it is about tuple unpacking that is not supported in python 3. Also you can check this thread .
Let's say you have rdd of tuples:
RDD = spark.sparkContext.range(0, 1).map(lambda a: (a, a))
below code will fail with SyntaxError: invalid syntax
RDD.map(lambda (a, b): a).collect()
but this will work correctly:
RDD.map(lambda a: a[0]).collect()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.