Python Pyspark将行矩阵转换为数据帧或RDD
我有一个正方形的pysparkPython Pyspark将行矩阵转换为数据帧或RDD,python,apache-spark,pyspark,spark-dataframe,apache-spark-ml,Python,Apache Spark,Pyspark,Spark Dataframe,Apache Spark Ml,我有一个正方形的pyspark行矩阵,看起来像这样: >>> row_mat.numRows() 100 >>> row_mat.numCols() 100 >>> row_mat.rows.first() SparseVector(100, {0: 0.0, 1: 0.0018, 2: 0.1562, 3: 0.0342...}) 我想运行,但它的方法只接受数据帧。有没有办法将此行矩阵转换为数据帧 或者有更好的方法吗?使用: row_ma
行矩阵
,看起来像这样:
>>> row_mat.numRows()
100
>>> row_mat.numCols()
100
>>> row_mat.rows.first()
SparseVector(100, {0: 0.0, 1: 0.0018, 2: 0.1562, 3: 0.0342...})
我想运行,但它的方法只接受数据帧
。有没有办法将此行矩阵
转换为数据帧
或者有更好的方法吗?使用:
row_mat.rows.map(lambda x: (x, )).toDF()
谢谢那真的很快,正是我想要的。