srowen commented on a change in pull request #24953: 
[SPARK-28140][MLLIB][PYTHON] Accept DataFrames in RowMatrix and 
IndexedRowMatrix constructors
URL: https://github.com/apache/spark/pull/24953#discussion_r296871693
 
 

 ##########
 File path: 
mllib/src/main/scala/org/apache/spark/mllib/api/python/PythonMLLibAPI.scala
 ##########
 @@ -1142,12 +1141,21 @@ private[python] class PythonMLLibAPI extends 
Serializable {
     new RowMatrix(rows.rdd, numRows, numCols)
   }
 
+  def createRowMatrix(df: DataFrame, numRows: Long, numCols: Int): RowMatrix = 
{
+    require(df.schema.length == 1 && df.schema.head.dataType.getClass == 
classOf[VectorUDT],
+      "DataFrame must have a single vector type column")
+    new RowMatrix(df.rdd.map { case Row(vector: Vector) => vector }, numRows, 
numCols)
 
 Review comment:
   This doesn't save much. In this case you can work out the number of rows and 
columns for the caller no? I get that this is to parallel the method below, 
which also doesn't do that. It should be possible to at least work out the 
number of rows.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to