Github user MechCoder commented on a diff in the pull request:
https://github.com/apache/spark/pull/7554#discussion_r35236115
--- Diff: docs/mllib-data-types.md ---
@@ -372,6 +372,29 @@ long m = mat.numRows();
long n = mat.numCols();
{% endhighlight %}
</div>
+
+<div data-lang="python" markdown="1">
+
+A
[`RowMatrix`](api/python/pyspark.mllib.html#pyspark.mllib.linalg.RowMatrix) can
be created from an `RDD` of Vectors.
+
+{% highlight python %}
+from pyspark.mllib.linalg import DistributedMatrices, Vectors
+
+# Create an RDD of Vectors.
+rows = sc.parallelize([Vectors.dense([1, 2, 3]), Vectors.dense([4, 5, 6]),
Vectors.dense([7, 8, 9]), Vectors.dense([10, 11, 12])])
+
+# Create a RowMatrix from an RDD[Vector].
+mat = DistributedMatrices.rowMatrix(rows)
+
+# Get its size.
+m = mat.numRows() # 4
--- End diff --
nitpick: I think it would be better to just print out the number of rows
and columns.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]