from pyspark.sql import Row
row_dict = {'C0': -1.1990072635132698,
'C3': 0.12605772684660232,
'C4': 0.5760856026559944,
'C5': 0.1951877800894315,
'C6': 24.72378589441825,
'summary': 'kurtosis'}
new_row = Row(row_dict)
上面这种方法会报错TypeError: sequence item 0: expected string, dict found
from pyspark.sql import Row
row_dict = {'C0': -1.1990072635132698,
'C3': 0.12605772684660232,
'C4': 0.5760856026559944,
'C5': 0.1951877800894315,
'C6': 24.72378589441825,
'summary': 'kurtosis'}
new_row = Row(**row_dict)
这样就可以了。
https://spark.apache.org/docs/1.0.2/api/python/pyspark.sql.Row-class.html
http://germanylandofinnovation.com/questions/27805/erstellen-einer-zeile-aus-einem-diktat-in-pyspark