diff options
author | Gaetan Semet <gaetan@xeberon.net> | 2016-09-12 12:21:33 +0100 |
---|---|---|
committer | Sean Owen <sowen@cloudera.com> | 2016-09-12 12:21:33 +0100 |
commit | b3c22912284c2a010a4af3c43dc5e6fd53c68f8c (patch) | |
tree | 6bc0d020f572db2ee79a7366b6fb495c1dcb2a81 /examples/src/main/python/ml | |
parent | 4efcdb7feae24e41d8120b59430f8b77cc2106a6 (diff) | |
download | spark-b3c22912284c2a010a4af3c43dc5e6fd53c68f8c.tar.gz spark-b3c22912284c2a010a4af3c43dc5e6fd53c68f8c.tar.bz2 spark-b3c22912284c2a010a4af3c43dc5e6fd53c68f8c.zip |
[SPARK-16992][PYSPARK] use map comprehension in doc
Code is equivalent, but map comprehency is most of the time faster than a map.
Author: Gaetan Semet <gaetan@xeberon.net>
Closes #14863 from Stibbons/map_comprehension.
Diffstat (limited to 'examples/src/main/python/ml')
-rw-r--r-- | examples/src/main/python/ml/quantile_discretizer_example.py | 2 | ||||
-rw-r--r-- | examples/src/main/python/ml/vector_slicer_example.py | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/examples/src/main/python/ml/quantile_discretizer_example.py b/examples/src/main/python/ml/quantile_discretizer_example.py index 788a0baffe..0fc1d1949a 100644 --- a/examples/src/main/python/ml/quantile_discretizer_example.py +++ b/examples/src/main/python/ml/quantile_discretizer_example.py @@ -29,7 +29,7 @@ if __name__ == "__main__": .getOrCreate() # $example on$ - data = [(0, 18.0,), (1, 19.0,), (2, 8.0,), (3, 5.0,), (4, 2.2,)] + data = [(0, 18.0), (1, 19.0), (2, 8.0), (3, 5.0), (4, 2.2)] df = spark.createDataFrame(data, ["id", "hour"]) # $example off$ diff --git a/examples/src/main/python/ml/vector_slicer_example.py b/examples/src/main/python/ml/vector_slicer_example.py index d2f46b190f..68c8cfe27e 100644 --- a/examples/src/main/python/ml/vector_slicer_example.py +++ b/examples/src/main/python/ml/vector_slicer_example.py @@ -32,8 +32,8 @@ if __name__ == "__main__": # $example on$ df = spark.createDataFrame([ - Row(userFeatures=Vectors.sparse(3, {0: -2.0, 1: 2.3}),), - Row(userFeatures=Vectors.dense([-2.0, 2.3, 0.0]),)]) + Row(userFeatures=Vectors.sparse(3, {0: -2.0, 1: 2.3})), + Row(userFeatures=Vectors.dense([-2.0, 2.3, 0.0]))]) slicer = VectorSlicer(inputCol="userFeatures", outputCol="features", indices=[1]) |