Github user MechCoder commented on a diff in the pull request:
https://github.com/apache/spark/pull/7554#discussion_r35237175
--- Diff: docs/mllib-data-types.md ---
@@ -431,7 +454,42 @@ long n = mat.numCols();
// Drop its row indices.
RowMatrix rowMat = mat.toRowMatrix();
{% endhighlight %}
-</div></div>
+</div>
+
+<div data-lang="python" markdown="1">
+
+An
[`IndexedRowMatrix`](api/python/pyspark.mllib.html#pyspark.mllib.linalg.IndexedRowMatrix)
can be created from an
+`RDD` of IndexedRows, where
[`IndexedRow`](api/python/pyspark.mllib.html#pyspark.mllib.linalg.IndexedRow)
is a
+wrapper over `(long, Vector)`. An `IndexedRowMatrix` can be converted to
a `RowMatrix` by dropping its row indices.
+
+{% highlight python %}
+from pyspark.mllib.linalg import Vectors, DistributedMatrices, IndexedRow,
IndexedRowMatrix
+
+# Create an RDD of indexed rows.
+# - This can be done explicitly with the IndexedRow class:
+indexedRows = sc.parallelize([IndexedRow(0,Vectors.dense([1, 2, 3])),
IndexedRow(1,Vectors.dense([4, 5, 6])), IndexedRow(2,Vectors.dense([7, 8, 9])),
IndexedRow(3,Vectors.dense([10, 11, 12]))])
--- End diff --
please line break and add spaces after commas.
---
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]