repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
apache/spark | python/pyspark/rdd.py | RDD.groupByKey | def groupByKey(self, numPartitions=None, partitionFunc=portable_hash):
"""
Group the values for each key in the RDD into a single sequence.
Hash-partitions the resulting RDD with numPartitions partitions.
.. note:: If you are grouping in order to perform an aggregation (such as a
... | python | def groupByKey(self, numPartitions=None, partitionFunc=portable_hash):
"""
Group the values for each key in the RDD into a single sequence.
Hash-partitions the resulting RDD with numPartitions partitions.
.. note:: If you are grouping in order to perform an aggregation (such as a
... | [
"def",
"groupByKey",
"(",
"self",
",",
"numPartitions",
"=",
"None",
",",
"partitionFunc",
"=",
"portable_hash",
")",
":",
"def",
"createCombiner",
"(",
"x",
")",
":",
"return",
"[",
"x",
"]",
"def",
"mergeValue",
"(",
"xs",
",",
"x",
")",
":",
"xs",
... | Group the values for each key in the RDD into a single sequence.
Hash-partitions the resulting RDD with numPartitions partitions.
.. note:: If you are grouping in order to perform an aggregation (such as a
sum or average) over each key, using reduceByKey or aggregateByKey will
p... | [
"Group",
"the",
"values",
"for",
"each",
"key",
"in",
"the",
"RDD",
"into",
"a",
"single",
"sequence",
".",
"Hash",
"-",
"partitions",
"the",
"resulting",
"RDD",
"with",
"numPartitions",
"partitions",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L1915-L1958 | train |
apache/spark | python/pyspark/rdd.py | RDD.flatMapValues | def flatMapValues(self, f):
"""
Pass each value in the key-value pair RDD through a flatMap function
without changing the keys; this also retains the original RDD's
partitioning.
>>> x = sc.parallelize([("a", ["x", "y", "z"]), ("b", ["p", "r"])])
>>> def f(x): return x
... | python | def flatMapValues(self, f):
"""
Pass each value in the key-value pair RDD through a flatMap function
without changing the keys; this also retains the original RDD's
partitioning.
>>> x = sc.parallelize([("a", ["x", "y", "z"]), ("b", ["p", "r"])])
>>> def f(x): return x
... | [
"def",
"flatMapValues",
"(",
"self",
",",
"f",
")",
":",
"flat_map_fn",
"=",
"lambda",
"kv",
":",
"(",
"(",
"kv",
"[",
"0",
"]",
",",
"x",
")",
"for",
"x",
"in",
"f",
"(",
"kv",
"[",
"1",
"]",
")",
")",
"return",
"self",
".",
"flatMap",
"(",
... | Pass each value in the key-value pair RDD through a flatMap function
without changing the keys; this also retains the original RDD's
partitioning.
>>> x = sc.parallelize([("a", ["x", "y", "z"]), ("b", ["p", "r"])])
>>> def f(x): return x
>>> x.flatMapValues(f).collect()
... | [
"Pass",
"each",
"value",
"in",
"the",
"key",
"-",
"value",
"pair",
"RDD",
"through",
"a",
"flatMap",
"function",
"without",
"changing",
"the",
"keys",
";",
"this",
"also",
"retains",
"the",
"original",
"RDD",
"s",
"partitioning",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L1960-L1972 | train |
apache/spark | python/pyspark/rdd.py | RDD.mapValues | def mapValues(self, f):
"""
Pass each value in the key-value pair RDD through a map function
without changing the keys; this also retains the original RDD's
partitioning.
>>> x = sc.parallelize([("a", ["apple", "banana", "lemon"]), ("b", ["grapes"])])
>>> def f(x): retur... | python | def mapValues(self, f):
"""
Pass each value in the key-value pair RDD through a map function
without changing the keys; this also retains the original RDD's
partitioning.
>>> x = sc.parallelize([("a", ["apple", "banana", "lemon"]), ("b", ["grapes"])])
>>> def f(x): retur... | [
"def",
"mapValues",
"(",
"self",
",",
"f",
")",
":",
"map_values_fn",
"=",
"lambda",
"kv",
":",
"(",
"kv",
"[",
"0",
"]",
",",
"f",
"(",
"kv",
"[",
"1",
"]",
")",
")",
"return",
"self",
".",
"map",
"(",
"map_values_fn",
",",
"preservesPartitioning"... | Pass each value in the key-value pair RDD through a map function
without changing the keys; this also retains the original RDD's
partitioning.
>>> x = sc.parallelize([("a", ["apple", "banana", "lemon"]), ("b", ["grapes"])])
>>> def f(x): return len(x)
>>> x.mapValues(f).collect(... | [
"Pass",
"each",
"value",
"in",
"the",
"key",
"-",
"value",
"pair",
"RDD",
"through",
"a",
"map",
"function",
"without",
"changing",
"the",
"keys",
";",
"this",
"also",
"retains",
"the",
"original",
"RDD",
"s",
"partitioning",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L1974-L1986 | train |
apache/spark | python/pyspark/rdd.py | RDD.sampleByKey | def sampleByKey(self, withReplacement, fractions, seed=None):
"""
Return a subset of this RDD sampled by key (via stratified sampling).
Create a sample of this RDD using variable sampling rates for
different keys as specified by fractions, a key to sampling rate map.
>>> fractio... | python | def sampleByKey(self, withReplacement, fractions, seed=None):
"""
Return a subset of this RDD sampled by key (via stratified sampling).
Create a sample of this RDD using variable sampling rates for
different keys as specified by fractions, a key to sampling rate map.
>>> fractio... | [
"def",
"sampleByKey",
"(",
"self",
",",
"withReplacement",
",",
"fractions",
",",
"seed",
"=",
"None",
")",
":",
"for",
"fraction",
"in",
"fractions",
".",
"values",
"(",
")",
":",
"assert",
"fraction",
">=",
"0.0",
",",
"\"Negative fraction value: %s\"",
"%... | Return a subset of this RDD sampled by key (via stratified sampling).
Create a sample of this RDD using variable sampling rates for
different keys as specified by fractions, a key to sampling rate map.
>>> fractions = {"a": 0.2, "b": 0.1}
>>> rdd = sc.parallelize(fractions.keys()).carte... | [
"Return",
"a",
"subset",
"of",
"this",
"RDD",
"sampled",
"by",
"key",
"(",
"via",
"stratified",
"sampling",
")",
".",
"Create",
"a",
"sample",
"of",
"this",
"RDD",
"using",
"variable",
"sampling",
"rates",
"for",
"different",
"keys",
"as",
"specified",
"by... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L2016-L2035 | train |
apache/spark | python/pyspark/rdd.py | RDD.subtractByKey | def subtractByKey(self, other, numPartitions=None):
"""
Return each (key, value) pair in C{self} that has no pair with matching
key in C{other}.
>>> x = sc.parallelize([("a", 1), ("b", 4), ("b", 5), ("a", 2)])
>>> y = sc.parallelize([("a", 3), ("c", None)])
>>> sorted(x.... | python | def subtractByKey(self, other, numPartitions=None):
"""
Return each (key, value) pair in C{self} that has no pair with matching
key in C{other}.
>>> x = sc.parallelize([("a", 1), ("b", 4), ("b", 5), ("a", 2)])
>>> y = sc.parallelize([("a", 3), ("c", None)])
>>> sorted(x.... | [
"def",
"subtractByKey",
"(",
"self",
",",
"other",
",",
"numPartitions",
"=",
"None",
")",
":",
"def",
"filter_func",
"(",
"pair",
")",
":",
"key",
",",
"(",
"val1",
",",
"val2",
")",
"=",
"pair",
"return",
"val1",
"and",
"not",
"val2",
"return",
"se... | Return each (key, value) pair in C{self} that has no pair with matching
key in C{other}.
>>> x = sc.parallelize([("a", 1), ("b", 4), ("b", 5), ("a", 2)])
>>> y = sc.parallelize([("a", 3), ("c", None)])
>>> sorted(x.subtractByKey(y).collect())
[('b', 4), ('b', 5)] | [
"Return",
"each",
"(",
"key",
"value",
")",
"pair",
"in",
"C",
"{",
"self",
"}",
"that",
"has",
"no",
"pair",
"with",
"matching",
"key",
"in",
"C",
"{",
"other",
"}",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L2037-L2050 | train |
apache/spark | python/pyspark/rdd.py | RDD.subtract | def subtract(self, other, numPartitions=None):
"""
Return each value in C{self} that is not contained in C{other}.
>>> x = sc.parallelize([("a", 1), ("b", 4), ("b", 5), ("a", 3)])
>>> y = sc.parallelize([("a", 3), ("c", None)])
>>> sorted(x.subtract(y).collect())
[('a', ... | python | def subtract(self, other, numPartitions=None):
"""
Return each value in C{self} that is not contained in C{other}.
>>> x = sc.parallelize([("a", 1), ("b", 4), ("b", 5), ("a", 3)])
>>> y = sc.parallelize([("a", 3), ("c", None)])
>>> sorted(x.subtract(y).collect())
[('a', ... | [
"def",
"subtract",
"(",
"self",
",",
"other",
",",
"numPartitions",
"=",
"None",
")",
":",
"# note: here 'True' is just a placeholder",
"rdd",
"=",
"other",
".",
"map",
"(",
"lambda",
"x",
":",
"(",
"x",
",",
"True",
")",
")",
"return",
"self",
".",
"map... | Return each value in C{self} that is not contained in C{other}.
>>> x = sc.parallelize([("a", 1), ("b", 4), ("b", 5), ("a", 3)])
>>> y = sc.parallelize([("a", 3), ("c", None)])
>>> sorted(x.subtract(y).collect())
[('a', 1), ('b', 4), ('b', 5)] | [
"Return",
"each",
"value",
"in",
"C",
"{",
"self",
"}",
"that",
"is",
"not",
"contained",
"in",
"C",
"{",
"other",
"}",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L2052-L2063 | train |
apache/spark | python/pyspark/rdd.py | RDD.coalesce | def coalesce(self, numPartitions, shuffle=False):
"""
Return a new RDD that is reduced into `numPartitions` partitions.
>>> sc.parallelize([1, 2, 3, 4, 5], 3).glom().collect()
[[1], [2, 3], [4, 5]]
>>> sc.parallelize([1, 2, 3, 4, 5], 3).coalesce(1).glom().collect()
[[1, ... | python | def coalesce(self, numPartitions, shuffle=False):
"""
Return a new RDD that is reduced into `numPartitions` partitions.
>>> sc.parallelize([1, 2, 3, 4, 5], 3).glom().collect()
[[1], [2, 3], [4, 5]]
>>> sc.parallelize([1, 2, 3, 4, 5], 3).coalesce(1).glom().collect()
[[1, ... | [
"def",
"coalesce",
"(",
"self",
",",
"numPartitions",
",",
"shuffle",
"=",
"False",
")",
":",
"if",
"shuffle",
":",
"# Decrease the batch size in order to distribute evenly the elements across output",
"# partitions. Otherwise, repartition will possibly produce highly skewed partitio... | Return a new RDD that is reduced into `numPartitions` partitions.
>>> sc.parallelize([1, 2, 3, 4, 5], 3).glom().collect()
[[1], [2, 3], [4, 5]]
>>> sc.parallelize([1, 2, 3, 4, 5], 3).coalesce(1).glom().collect()
[[1, 2, 3, 4, 5]] | [
"Return",
"a",
"new",
"RDD",
"that",
"is",
"reduced",
"into",
"numPartitions",
"partitions",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L2095-L2115 | train |
apache/spark | python/pyspark/rdd.py | RDD.zip | def zip(self, other):
"""
Zips this RDD with another one, returning key-value pairs with the
first element in each RDD second element in each RDD, etc. Assumes
that the two RDDs have the same number of partitions and the same
number of elements in each partition (e.g. one was mad... | python | def zip(self, other):
"""
Zips this RDD with another one, returning key-value pairs with the
first element in each RDD second element in each RDD, etc. Assumes
that the two RDDs have the same number of partitions and the same
number of elements in each partition (e.g. one was mad... | [
"def",
"zip",
"(",
"self",
",",
"other",
")",
":",
"def",
"get_batch_size",
"(",
"ser",
")",
":",
"if",
"isinstance",
"(",
"ser",
",",
"BatchedSerializer",
")",
":",
"return",
"ser",
".",
"batchSize",
"return",
"1",
"# not batched",
"def",
"batch_as",
"(... | Zips this RDD with another one, returning key-value pairs with the
first element in each RDD second element in each RDD, etc. Assumes
that the two RDDs have the same number of partitions and the same
number of elements in each partition (e.g. one was made through
a map on the other).
... | [
"Zips",
"this",
"RDD",
"with",
"another",
"one",
"returning",
"key",
"-",
"value",
"pairs",
"with",
"the",
"first",
"element",
"in",
"each",
"RDD",
"second",
"element",
"in",
"each",
"RDD",
"etc",
".",
"Assumes",
"that",
"the",
"two",
"RDDs",
"have",
"th... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L2117-L2157 | train |
apache/spark | python/pyspark/rdd.py | RDD.zipWithIndex | def zipWithIndex(self):
"""
Zips this RDD with its element indices.
The ordering is first based on the partition index and then the
ordering of items within each partition. So the first item in
the first partition gets index 0, and the last item in the last
partition rec... | python | def zipWithIndex(self):
"""
Zips this RDD with its element indices.
The ordering is first based on the partition index and then the
ordering of items within each partition. So the first item in
the first partition gets index 0, and the last item in the last
partition rec... | [
"def",
"zipWithIndex",
"(",
"self",
")",
":",
"starts",
"=",
"[",
"0",
"]",
"if",
"self",
".",
"getNumPartitions",
"(",
")",
">",
"1",
":",
"nums",
"=",
"self",
".",
"mapPartitions",
"(",
"lambda",
"it",
":",
"[",
"sum",
"(",
"1",
"for",
"i",
"in... | Zips this RDD with its element indices.
The ordering is first based on the partition index and then the
ordering of items within each partition. So the first item in
the first partition gets index 0, and the last item in the last
partition receives the largest index.
This metho... | [
"Zips",
"this",
"RDD",
"with",
"its",
"element",
"indices",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L2159-L2184 | train |
apache/spark | python/pyspark/rdd.py | RDD.zipWithUniqueId | def zipWithUniqueId(self):
"""
Zips this RDD with generated unique Long ids.
Items in the kth partition will get ids k, n+k, 2*n+k, ..., where
n is the number of partitions. So there may exist gaps, but this
method won't trigger a spark job, which is different from
L{zip... | python | def zipWithUniqueId(self):
"""
Zips this RDD with generated unique Long ids.
Items in the kth partition will get ids k, n+k, 2*n+k, ..., where
n is the number of partitions. So there may exist gaps, but this
method won't trigger a spark job, which is different from
L{zip... | [
"def",
"zipWithUniqueId",
"(",
"self",
")",
":",
"n",
"=",
"self",
".",
"getNumPartitions",
"(",
")",
"def",
"func",
"(",
"k",
",",
"it",
")",
":",
"for",
"i",
",",
"v",
"in",
"enumerate",
"(",
"it",
")",
":",
"yield",
"v",
",",
"i",
"*",
"n",
... | Zips this RDD with generated unique Long ids.
Items in the kth partition will get ids k, n+k, 2*n+k, ..., where
n is the number of partitions. So there may exist gaps, but this
method won't trigger a spark job, which is different from
L{zipWithIndex}
>>> sc.parallelize(["a", "b... | [
"Zips",
"this",
"RDD",
"with",
"generated",
"unique",
"Long",
"ids",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L2186-L2204 | train |
apache/spark | python/pyspark/rdd.py | RDD.getStorageLevel | def getStorageLevel(self):
"""
Get the RDD's current storage level.
>>> rdd1 = sc.parallelize([1,2])
>>> rdd1.getStorageLevel()
StorageLevel(False, False, False, False, 1)
>>> print(rdd1.getStorageLevel())
Serialized 1x Replicated
"""
java_storage... | python | def getStorageLevel(self):
"""
Get the RDD's current storage level.
>>> rdd1 = sc.parallelize([1,2])
>>> rdd1.getStorageLevel()
StorageLevel(False, False, False, False, 1)
>>> print(rdd1.getStorageLevel())
Serialized 1x Replicated
"""
java_storage... | [
"def",
"getStorageLevel",
"(",
"self",
")",
":",
"java_storage_level",
"=",
"self",
".",
"_jrdd",
".",
"getStorageLevel",
"(",
")",
"storage_level",
"=",
"StorageLevel",
"(",
"java_storage_level",
".",
"useDisk",
"(",
")",
",",
"java_storage_level",
".",
"useMem... | Get the RDD's current storage level.
>>> rdd1 = sc.parallelize([1,2])
>>> rdd1.getStorageLevel()
StorageLevel(False, False, False, False, 1)
>>> print(rdd1.getStorageLevel())
Serialized 1x Replicated | [
"Get",
"the",
"RDD",
"s",
"current",
"storage",
"level",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L2234-L2250 | train |
apache/spark | python/pyspark/rdd.py | RDD._defaultReducePartitions | def _defaultReducePartitions(self):
"""
Returns the default number of partitions to use during reduce tasks (e.g., groupBy).
If spark.default.parallelism is set, then we'll use the value from SparkContext
defaultParallelism, otherwise we'll use the number of partitions in this RDD.
... | python | def _defaultReducePartitions(self):
"""
Returns the default number of partitions to use during reduce tasks (e.g., groupBy).
If spark.default.parallelism is set, then we'll use the value from SparkContext
defaultParallelism, otherwise we'll use the number of partitions in this RDD.
... | [
"def",
"_defaultReducePartitions",
"(",
"self",
")",
":",
"if",
"self",
".",
"ctx",
".",
"_conf",
".",
"contains",
"(",
"\"spark.default.parallelism\"",
")",
":",
"return",
"self",
".",
"ctx",
".",
"defaultParallelism",
"else",
":",
"return",
"self",
".",
"g... | Returns the default number of partitions to use during reduce tasks (e.g., groupBy).
If spark.default.parallelism is set, then we'll use the value from SparkContext
defaultParallelism, otherwise we'll use the number of partitions in this RDD.
This mirrors the behavior of the Scala Partitioner#d... | [
"Returns",
"the",
"default",
"number",
"of",
"partitions",
"to",
"use",
"during",
"reduce",
"tasks",
"(",
"e",
".",
"g",
".",
"groupBy",
")",
".",
"If",
"spark",
".",
"default",
".",
"parallelism",
"is",
"set",
"then",
"we",
"ll",
"use",
"the",
"value"... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L2252-L2265 | train |
apache/spark | python/pyspark/rdd.py | RDD.lookup | def lookup(self, key):
"""
Return the list of values in the RDD for key `key`. This operation
is done efficiently if the RDD has a known partitioner by only
searching the partition that the key maps to.
>>> l = range(1000)
>>> rdd = sc.parallelize(zip(l, l), 10)
... | python | def lookup(self, key):
"""
Return the list of values in the RDD for key `key`. This operation
is done efficiently if the RDD has a known partitioner by only
searching the partition that the key maps to.
>>> l = range(1000)
>>> rdd = sc.parallelize(zip(l, l), 10)
... | [
"def",
"lookup",
"(",
"self",
",",
"key",
")",
":",
"values",
"=",
"self",
".",
"filter",
"(",
"lambda",
"kv",
":",
"kv",
"[",
"0",
"]",
"==",
"key",
")",
".",
"values",
"(",
")",
"if",
"self",
".",
"partitioner",
"is",
"not",
"None",
":",
"ret... | Return the list of values in the RDD for key `key`. This operation
is done efficiently if the RDD has a known partitioner by only
searching the partition that the key maps to.
>>> l = range(1000)
>>> rdd = sc.parallelize(zip(l, l), 10)
>>> rdd.lookup(42) # slow
[42]
... | [
"Return",
"the",
"list",
"of",
"values",
"in",
"the",
"RDD",
"for",
"key",
"key",
".",
"This",
"operation",
"is",
"done",
"efficiently",
"if",
"the",
"RDD",
"has",
"a",
"known",
"partitioner",
"by",
"only",
"searching",
"the",
"partition",
"that",
"the",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L2267-L2291 | train |
apache/spark | python/pyspark/rdd.py | RDD._to_java_object_rdd | def _to_java_object_rdd(self):
""" Return a JavaRDD of Object by unpickling
It will convert each Python object into Java object by Pyrolite, whenever the
RDD is serialized in batch or not.
"""
rdd = self._pickled()
return self.ctx._jvm.SerDeUtil.pythonToJava(rdd._jrdd, T... | python | def _to_java_object_rdd(self):
""" Return a JavaRDD of Object by unpickling
It will convert each Python object into Java object by Pyrolite, whenever the
RDD is serialized in batch or not.
"""
rdd = self._pickled()
return self.ctx._jvm.SerDeUtil.pythonToJava(rdd._jrdd, T... | [
"def",
"_to_java_object_rdd",
"(",
"self",
")",
":",
"rdd",
"=",
"self",
".",
"_pickled",
"(",
")",
"return",
"self",
".",
"ctx",
".",
"_jvm",
".",
"SerDeUtil",
".",
"pythonToJava",
"(",
"rdd",
".",
"_jrdd",
",",
"True",
")"
] | Return a JavaRDD of Object by unpickling
It will convert each Python object into Java object by Pyrolite, whenever the
RDD is serialized in batch or not. | [
"Return",
"a",
"JavaRDD",
"of",
"Object",
"by",
"unpickling"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L2293-L2300 | train |
apache/spark | python/pyspark/rdd.py | RDD.countApprox | def countApprox(self, timeout, confidence=0.95):
"""
.. note:: Experimental
Approximate version of count() that returns a potentially incomplete
result within a timeout, even if not all tasks have finished.
>>> rdd = sc.parallelize(range(1000), 10)
>>> rdd.countApprox(1... | python | def countApprox(self, timeout, confidence=0.95):
"""
.. note:: Experimental
Approximate version of count() that returns a potentially incomplete
result within a timeout, even if not all tasks have finished.
>>> rdd = sc.parallelize(range(1000), 10)
>>> rdd.countApprox(1... | [
"def",
"countApprox",
"(",
"self",
",",
"timeout",
",",
"confidence",
"=",
"0.95",
")",
":",
"drdd",
"=",
"self",
".",
"mapPartitions",
"(",
"lambda",
"it",
":",
"[",
"float",
"(",
"sum",
"(",
"1",
"for",
"i",
"in",
"it",
")",
")",
"]",
")",
"ret... | .. note:: Experimental
Approximate version of count() that returns a potentially incomplete
result within a timeout, even if not all tasks have finished.
>>> rdd = sc.parallelize(range(1000), 10)
>>> rdd.countApprox(1000, 1.0)
1000 | [
"..",
"note",
"::",
"Experimental"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L2302-L2314 | train |
apache/spark | python/pyspark/rdd.py | RDD.sumApprox | def sumApprox(self, timeout, confidence=0.95):
"""
.. note:: Experimental
Approximate operation to return the sum within a timeout
or meet the confidence.
>>> rdd = sc.parallelize(range(1000), 10)
>>> r = sum(range(1000))
>>> abs(rdd.sumApprox(1000) - r) / r < 0... | python | def sumApprox(self, timeout, confidence=0.95):
"""
.. note:: Experimental
Approximate operation to return the sum within a timeout
or meet the confidence.
>>> rdd = sc.parallelize(range(1000), 10)
>>> r = sum(range(1000))
>>> abs(rdd.sumApprox(1000) - r) / r < 0... | [
"def",
"sumApprox",
"(",
"self",
",",
"timeout",
",",
"confidence",
"=",
"0.95",
")",
":",
"jrdd",
"=",
"self",
".",
"mapPartitions",
"(",
"lambda",
"it",
":",
"[",
"float",
"(",
"sum",
"(",
"it",
")",
")",
"]",
")",
".",
"_to_java_object_rdd",
"(",
... | .. note:: Experimental
Approximate operation to return the sum within a timeout
or meet the confidence.
>>> rdd = sc.parallelize(range(1000), 10)
>>> r = sum(range(1000))
>>> abs(rdd.sumApprox(1000) - r) / r < 0.05
True | [
"..",
"note",
"::",
"Experimental"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L2316-L2331 | train |
apache/spark | python/pyspark/rdd.py | RDD.meanApprox | def meanApprox(self, timeout, confidence=0.95):
"""
.. note:: Experimental
Approximate operation to return the mean within a timeout
or meet the confidence.
>>> rdd = sc.parallelize(range(1000), 10)
>>> r = sum(range(1000)) / 1000.0
>>> abs(rdd.meanApprox(1000) ... | python | def meanApprox(self, timeout, confidence=0.95):
"""
.. note:: Experimental
Approximate operation to return the mean within a timeout
or meet the confidence.
>>> rdd = sc.parallelize(range(1000), 10)
>>> r = sum(range(1000)) / 1000.0
>>> abs(rdd.meanApprox(1000) ... | [
"def",
"meanApprox",
"(",
"self",
",",
"timeout",
",",
"confidence",
"=",
"0.95",
")",
":",
"jrdd",
"=",
"self",
".",
"map",
"(",
"float",
")",
".",
"_to_java_object_rdd",
"(",
")",
"jdrdd",
"=",
"self",
".",
"ctx",
".",
"_jvm",
".",
"JavaDoubleRDD",
... | .. note:: Experimental
Approximate operation to return the mean within a timeout
or meet the confidence.
>>> rdd = sc.parallelize(range(1000), 10)
>>> r = sum(range(1000)) / 1000.0
>>> abs(rdd.meanApprox(1000) - r) / r < 0.05
True | [
"..",
"note",
"::",
"Experimental"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L2333-L2348 | train |
apache/spark | python/pyspark/rdd.py | RDD.countApproxDistinct | def countApproxDistinct(self, relativeSD=0.05):
"""
.. note:: Experimental
Return approximate number of distinct elements in the RDD.
The algorithm used is based on streamlib's implementation of
`"HyperLogLog in Practice: Algorithmic Engineering of a State
of The Art Ca... | python | def countApproxDistinct(self, relativeSD=0.05):
"""
.. note:: Experimental
Return approximate number of distinct elements in the RDD.
The algorithm used is based on streamlib's implementation of
`"HyperLogLog in Practice: Algorithmic Engineering of a State
of The Art Ca... | [
"def",
"countApproxDistinct",
"(",
"self",
",",
"relativeSD",
"=",
"0.05",
")",
":",
"if",
"relativeSD",
"<",
"0.000017",
":",
"raise",
"ValueError",
"(",
"\"relativeSD should be greater than 0.000017\"",
")",
"# the hash space in Java is 2^32",
"hashRDD",
"=",
"self",
... | .. note:: Experimental
Return approximate number of distinct elements in the RDD.
The algorithm used is based on streamlib's implementation of
`"HyperLogLog in Practice: Algorithmic Engineering of a State
of The Art Cardinality Estimation Algorithm", available here
<https://doi... | [
"..",
"note",
"::",
"Experimental"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L2350-L2376 | train |
apache/spark | python/pyspark/rdd.py | RDD.toLocalIterator | def toLocalIterator(self):
"""
Return an iterator that contains all of the elements in this RDD.
The iterator will consume as much memory as the largest partition in this RDD.
>>> rdd = sc.parallelize(range(10))
>>> [x for x in rdd.toLocalIterator()]
[0, 1, 2, 3, 4, 5, 6... | python | def toLocalIterator(self):
"""
Return an iterator that contains all of the elements in this RDD.
The iterator will consume as much memory as the largest partition in this RDD.
>>> rdd = sc.parallelize(range(10))
>>> [x for x in rdd.toLocalIterator()]
[0, 1, 2, 3, 4, 5, 6... | [
"def",
"toLocalIterator",
"(",
"self",
")",
":",
"with",
"SCCallSiteSync",
"(",
"self",
".",
"context",
")",
"as",
"css",
":",
"sock_info",
"=",
"self",
".",
"ctx",
".",
"_jvm",
".",
"PythonRDD",
".",
"toLocalIteratorAndServe",
"(",
"self",
".",
"_jrdd",
... | Return an iterator that contains all of the elements in this RDD.
The iterator will consume as much memory as the largest partition in this RDD.
>>> rdd = sc.parallelize(range(10))
>>> [x for x in rdd.toLocalIterator()]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | [
"Return",
"an",
"iterator",
"that",
"contains",
"all",
"of",
"the",
"elements",
"in",
"this",
"RDD",
".",
"The",
"iterator",
"will",
"consume",
"as",
"much",
"memory",
"as",
"the",
"largest",
"partition",
"in",
"this",
"RDD",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L2378-L2389 | train |
apache/spark | python/pyspark/rdd.py | RDDBarrier.mapPartitions | def mapPartitions(self, f, preservesPartitioning=False):
"""
.. note:: Experimental
Returns a new RDD by applying a function to each partition of the wrapped RDD,
where tasks are launched together in a barrier stage.
The interface is the same as :func:`RDD.mapPartitions`.
... | python | def mapPartitions(self, f, preservesPartitioning=False):
"""
.. note:: Experimental
Returns a new RDD by applying a function to each partition of the wrapped RDD,
where tasks are launched together in a barrier stage.
The interface is the same as :func:`RDD.mapPartitions`.
... | [
"def",
"mapPartitions",
"(",
"self",
",",
"f",
",",
"preservesPartitioning",
"=",
"False",
")",
":",
"def",
"func",
"(",
"s",
",",
"iterator",
")",
":",
"return",
"f",
"(",
"iterator",
")",
"return",
"PipelinedRDD",
"(",
"self",
".",
"rdd",
",",
"func"... | .. note:: Experimental
Returns a new RDD by applying a function to each partition of the wrapped RDD,
where tasks are launched together in a barrier stage.
The interface is the same as :func:`RDD.mapPartitions`.
Please see the API doc there.
.. versionadded:: 2.4.0 | [
"..",
"note",
"::",
"Experimental"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L2455-L2468 | train |
apache/spark | python/pyspark/sql/column.py | _to_seq | def _to_seq(sc, cols, converter=None):
"""
Convert a list of Column (or names) into a JVM Seq of Column.
An optional `converter` could be used to convert items in `cols`
into JVM Column objects.
"""
if converter:
cols = [converter(c) for c in cols]
return sc._jvm.PythonUtils.toSeq(c... | python | def _to_seq(sc, cols, converter=None):
"""
Convert a list of Column (or names) into a JVM Seq of Column.
An optional `converter` could be used to convert items in `cols`
into JVM Column objects.
"""
if converter:
cols = [converter(c) for c in cols]
return sc._jvm.PythonUtils.toSeq(c... | [
"def",
"_to_seq",
"(",
"sc",
",",
"cols",
",",
"converter",
"=",
"None",
")",
":",
"if",
"converter",
":",
"cols",
"=",
"[",
"converter",
"(",
"c",
")",
"for",
"c",
"in",
"cols",
"]",
"return",
"sc",
".",
"_jvm",
".",
"PythonUtils",
".",
"toSeq",
... | Convert a list of Column (or names) into a JVM Seq of Column.
An optional `converter` could be used to convert items in `cols`
into JVM Column objects. | [
"Convert",
"a",
"list",
"of",
"Column",
"(",
"or",
"names",
")",
"into",
"a",
"JVM",
"Seq",
"of",
"Column",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L57-L66 | train |
apache/spark | python/pyspark/sql/column.py | _to_list | def _to_list(sc, cols, converter=None):
"""
Convert a list of Column (or names) into a JVM (Scala) List of Column.
An optional `converter` could be used to convert items in `cols`
into JVM Column objects.
"""
if converter:
cols = [converter(c) for c in cols]
return sc._jvm.PythonUti... | python | def _to_list(sc, cols, converter=None):
"""
Convert a list of Column (or names) into a JVM (Scala) List of Column.
An optional `converter` could be used to convert items in `cols`
into JVM Column objects.
"""
if converter:
cols = [converter(c) for c in cols]
return sc._jvm.PythonUti... | [
"def",
"_to_list",
"(",
"sc",
",",
"cols",
",",
"converter",
"=",
"None",
")",
":",
"if",
"converter",
":",
"cols",
"=",
"[",
"converter",
"(",
"c",
")",
"for",
"c",
"in",
"cols",
"]",
"return",
"sc",
".",
"_jvm",
".",
"PythonUtils",
".",
"toList",... | Convert a list of Column (or names) into a JVM (Scala) List of Column.
An optional `converter` could be used to convert items in `cols`
into JVM Column objects. | [
"Convert",
"a",
"list",
"of",
"Column",
"(",
"or",
"names",
")",
"into",
"a",
"JVM",
"(",
"Scala",
")",
"List",
"of",
"Column",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L69-L78 | train |
apache/spark | python/pyspark/sql/column.py | _unary_op | def _unary_op(name, doc="unary operator"):
""" Create a method for given unary operator """
def _(self):
jc = getattr(self._jc, name)()
return Column(jc)
_.__doc__ = doc
return _ | python | def _unary_op(name, doc="unary operator"):
""" Create a method for given unary operator """
def _(self):
jc = getattr(self._jc, name)()
return Column(jc)
_.__doc__ = doc
return _ | [
"def",
"_unary_op",
"(",
"name",
",",
"doc",
"=",
"\"unary operator\"",
")",
":",
"def",
"_",
"(",
"self",
")",
":",
"jc",
"=",
"getattr",
"(",
"self",
".",
"_jc",
",",
"name",
")",
"(",
")",
"return",
"Column",
"(",
"jc",
")",
"_",
".",
"__doc__... | Create a method for given unary operator | [
"Create",
"a",
"method",
"for",
"given",
"unary",
"operator"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L81-L87 | train |
apache/spark | python/pyspark/sql/column.py | _bin_op | def _bin_op(name, doc="binary operator"):
""" Create a method for given binary operator
"""
def _(self, other):
jc = other._jc if isinstance(other, Column) else other
njc = getattr(self._jc, name)(jc)
return Column(njc)
_.__doc__ = doc
return _ | python | def _bin_op(name, doc="binary operator"):
""" Create a method for given binary operator
"""
def _(self, other):
jc = other._jc if isinstance(other, Column) else other
njc = getattr(self._jc, name)(jc)
return Column(njc)
_.__doc__ = doc
return _ | [
"def",
"_bin_op",
"(",
"name",
",",
"doc",
"=",
"\"binary operator\"",
")",
":",
"def",
"_",
"(",
"self",
",",
"other",
")",
":",
"jc",
"=",
"other",
".",
"_jc",
"if",
"isinstance",
"(",
"other",
",",
"Column",
")",
"else",
"other",
"njc",
"=",
"ge... | Create a method for given binary operator | [
"Create",
"a",
"method",
"for",
"given",
"binary",
"operator"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L110-L118 | train |
apache/spark | python/pyspark/sql/column.py | _reverse_op | def _reverse_op(name, doc="binary operator"):
""" Create a method for binary operator (this object is on right side)
"""
def _(self, other):
jother = _create_column_from_literal(other)
jc = getattr(jother, name)(self._jc)
return Column(jc)
_.__doc__ = doc
return _ | python | def _reverse_op(name, doc="binary operator"):
""" Create a method for binary operator (this object is on right side)
"""
def _(self, other):
jother = _create_column_from_literal(other)
jc = getattr(jother, name)(self._jc)
return Column(jc)
_.__doc__ = doc
return _ | [
"def",
"_reverse_op",
"(",
"name",
",",
"doc",
"=",
"\"binary operator\"",
")",
":",
"def",
"_",
"(",
"self",
",",
"other",
")",
":",
"jother",
"=",
"_create_column_from_literal",
"(",
"other",
")",
"jc",
"=",
"getattr",
"(",
"jother",
",",
"name",
")",
... | Create a method for binary operator (this object is on right side) | [
"Create",
"a",
"method",
"for",
"binary",
"operator",
"(",
"this",
"object",
"is",
"on",
"right",
"side",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L121-L129 | train |
apache/spark | python/pyspark/sql/column.py | Column.substr | def substr(self, startPos, length):
"""
Return a :class:`Column` which is a substring of the column.
:param startPos: start position (int or Column)
:param length: length of the substring (int or Column)
>>> df.select(df.name.substr(1, 3).alias("col")).collect()
[Row(c... | python | def substr(self, startPos, length):
"""
Return a :class:`Column` which is a substring of the column.
:param startPos: start position (int or Column)
:param length: length of the substring (int or Column)
>>> df.select(df.name.substr(1, 3).alias("col")).collect()
[Row(c... | [
"def",
"substr",
"(",
"self",
",",
"startPos",
",",
"length",
")",
":",
"if",
"type",
"(",
"startPos",
")",
"!=",
"type",
"(",
"length",
")",
":",
"raise",
"TypeError",
"(",
"\"startPos and length must be the same type. \"",
"\"Got {startPos_t} and {length_t}, respe... | Return a :class:`Column` which is a substring of the column.
:param startPos: start position (int or Column)
:param length: length of the substring (int or Column)
>>> df.select(df.name.substr(1, 3).alias("col")).collect()
[Row(col=u'Ali'), Row(col=u'Bob')] | [
"Return",
"a",
":",
"class",
":",
"Column",
"which",
"is",
"a",
"substring",
"of",
"the",
"column",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L403-L427 | train |
apache/spark | python/pyspark/sql/column.py | Column.isin | def isin(self, *cols):
"""
A boolean expression that is evaluated to true if the value of this
expression is contained by the evaluated values of the arguments.
>>> df[df.name.isin("Bob", "Mike")].collect()
[Row(age=5, name=u'Bob')]
>>> df[df.age.isin([1, 2, 3])].collect... | python | def isin(self, *cols):
"""
A boolean expression that is evaluated to true if the value of this
expression is contained by the evaluated values of the arguments.
>>> df[df.name.isin("Bob", "Mike")].collect()
[Row(age=5, name=u'Bob')]
>>> df[df.age.isin([1, 2, 3])].collect... | [
"def",
"isin",
"(",
"self",
",",
"*",
"cols",
")",
":",
"if",
"len",
"(",
"cols",
")",
"==",
"1",
"and",
"isinstance",
"(",
"cols",
"[",
"0",
"]",
",",
"(",
"list",
",",
"set",
")",
")",
":",
"cols",
"=",
"cols",
"[",
"0",
"]",
"cols",
"=",... | A boolean expression that is evaluated to true if the value of this
expression is contained by the evaluated values of the arguments.
>>> df[df.name.isin("Bob", "Mike")].collect()
[Row(age=5, name=u'Bob')]
>>> df[df.age.isin([1, 2, 3])].collect()
[Row(age=2, name=u'Alice')] | [
"A",
"boolean",
"expression",
"that",
"is",
"evaluated",
"to",
"true",
"if",
"the",
"value",
"of",
"this",
"expression",
"is",
"contained",
"by",
"the",
"evaluated",
"values",
"of",
"the",
"arguments",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L431-L446 | train |
apache/spark | python/pyspark/sql/column.py | Column.alias | def alias(self, *alias, **kwargs):
"""
Returns this column aliased with a new name or names (in the case of expressions that
return more than one column, such as explode).
:param alias: strings of desired column names (collects all positional arguments passed)
:param metadata: a... | python | def alias(self, *alias, **kwargs):
"""
Returns this column aliased with a new name or names (in the case of expressions that
return more than one column, such as explode).
:param alias: strings of desired column names (collects all positional arguments passed)
:param metadata: a... | [
"def",
"alias",
"(",
"self",
",",
"*",
"alias",
",",
"*",
"*",
"kwargs",
")",
":",
"metadata",
"=",
"kwargs",
".",
"pop",
"(",
"'metadata'",
",",
"None",
")",
"assert",
"not",
"kwargs",
",",
"'Unexpected kwargs where passed: %s'",
"%",
"kwargs",
"sc",
"=... | Returns this column aliased with a new name or names (in the case of expressions that
return more than one column, such as explode).
:param alias: strings of desired column names (collects all positional arguments passed)
:param metadata: a dict of information to be stored in ``metadata`` attri... | [
"Returns",
"this",
"column",
"aliased",
"with",
"a",
"new",
"name",
"or",
"names",
"(",
"in",
"the",
"case",
"of",
"expressions",
"that",
"return",
"more",
"than",
"one",
"column",
"such",
"as",
"explode",
")",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L538-L570 | train |
apache/spark | python/pyspark/sql/column.py | Column.cast | def cast(self, dataType):
""" Convert the column into type ``dataType``.
>>> df.select(df.age.cast("string").alias('ages')).collect()
[Row(ages=u'2'), Row(ages=u'5')]
>>> df.select(df.age.cast(StringType()).alias('ages')).collect()
[Row(ages=u'2'), Row(ages=u'5')]
"""
... | python | def cast(self, dataType):
""" Convert the column into type ``dataType``.
>>> df.select(df.age.cast("string").alias('ages')).collect()
[Row(ages=u'2'), Row(ages=u'5')]
>>> df.select(df.age.cast(StringType()).alias('ages')).collect()
[Row(ages=u'2'), Row(ages=u'5')]
"""
... | [
"def",
"cast",
"(",
"self",
",",
"dataType",
")",
":",
"if",
"isinstance",
"(",
"dataType",
",",
"basestring",
")",
":",
"jc",
"=",
"self",
".",
"_jc",
".",
"cast",
"(",
"dataType",
")",
"elif",
"isinstance",
"(",
"dataType",
",",
"DataType",
")",
":... | Convert the column into type ``dataType``.
>>> df.select(df.age.cast("string").alias('ages')).collect()
[Row(ages=u'2'), Row(ages=u'5')]
>>> df.select(df.age.cast(StringType()).alias('ages')).collect()
[Row(ages=u'2'), Row(ages=u'5')] | [
"Convert",
"the",
"column",
"into",
"type",
"dataType",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L576-L593 | train |
apache/spark | python/pyspark/sql/column.py | Column.when | def when(self, condition, value):
"""
Evaluates a list of conditions and returns one of multiple possible result expressions.
If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions.
See :func:`pyspark.sql.functions.when` for example usage.
:param ... | python | def when(self, condition, value):
"""
Evaluates a list of conditions and returns one of multiple possible result expressions.
If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions.
See :func:`pyspark.sql.functions.when` for example usage.
:param ... | [
"def",
"when",
"(",
"self",
",",
"condition",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"condition",
",",
"Column",
")",
":",
"raise",
"TypeError",
"(",
"\"condition should be a Column\"",
")",
"v",
"=",
"value",
".",
"_jc",
"if",
"isinstance... | Evaluates a list of conditions and returns one of multiple possible result expressions.
If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions.
See :func:`pyspark.sql.functions.when` for example usage.
:param condition: a boolean :class:`Column` expression.
... | [
"Evaluates",
"a",
"list",
"of",
"conditions",
"and",
"returns",
"one",
"of",
"multiple",
"possible",
"result",
"expressions",
".",
"If",
":",
"func",
":",
"Column",
".",
"otherwise",
"is",
"not",
"invoked",
"None",
"is",
"returned",
"for",
"unmatched",
"cond... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L614-L637 | train |
apache/spark | python/pyspark/sql/column.py | Column.otherwise | def otherwise(self, value):
"""
Evaluates a list of conditions and returns one of multiple possible result expressions.
If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions.
See :func:`pyspark.sql.functions.when` for example usage.
:param value:... | python | def otherwise(self, value):
"""
Evaluates a list of conditions and returns one of multiple possible result expressions.
If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions.
See :func:`pyspark.sql.functions.when` for example usage.
:param value:... | [
"def",
"otherwise",
"(",
"self",
",",
"value",
")",
":",
"v",
"=",
"value",
".",
"_jc",
"if",
"isinstance",
"(",
"value",
",",
"Column",
")",
"else",
"value",
"jc",
"=",
"self",
".",
"_jc",
".",
"otherwise",
"(",
"v",
")",
"return",
"Column",
"(",
... | Evaluates a list of conditions and returns one of multiple possible result expressions.
If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions.
See :func:`pyspark.sql.functions.when` for example usage.
:param value: a literal value, or a :class:`Column` expressio... | [
"Evaluates",
"a",
"list",
"of",
"conditions",
"and",
"returns",
"one",
"of",
"multiple",
"possible",
"result",
"expressions",
".",
"If",
":",
"func",
":",
"Column",
".",
"otherwise",
"is",
"not",
"invoked",
"None",
"is",
"returned",
"for",
"unmatched",
"cond... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L640-L660 | train |
apache/spark | python/pyspark/sql/column.py | Column.over | def over(self, window):
"""
Define a windowing column.
:param window: a :class:`WindowSpec`
:return: a Column
>>> from pyspark.sql import Window
>>> window = Window.partitionBy("name").orderBy("age").rowsBetween(-1, 1)
>>> from pyspark.sql.functions import rank,... | python | def over(self, window):
"""
Define a windowing column.
:param window: a :class:`WindowSpec`
:return: a Column
>>> from pyspark.sql import Window
>>> window = Window.partitionBy("name").orderBy("age").rowsBetween(-1, 1)
>>> from pyspark.sql.functions import rank,... | [
"def",
"over",
"(",
"self",
",",
"window",
")",
":",
"from",
"pyspark",
".",
"sql",
".",
"window",
"import",
"WindowSpec",
"if",
"not",
"isinstance",
"(",
"window",
",",
"WindowSpec",
")",
":",
"raise",
"TypeError",
"(",
"\"window should be WindowSpec\"",
")... | Define a windowing column.
:param window: a :class:`WindowSpec`
:return: a Column
>>> from pyspark.sql import Window
>>> window = Window.partitionBy("name").orderBy("age").rowsBetween(-1, 1)
>>> from pyspark.sql.functions import rank, min
>>> # df.select(rank().over(win... | [
"Define",
"a",
"windowing",
"column",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L663-L679 | train |
apache/spark | python/pyspark/mllib/feature.py | JavaVectorTransformer.transform | def transform(self, vector):
"""
Applies transformation on a vector or an RDD[Vector].
.. note:: In Python, transform cannot currently be used within
an RDD transformation or action.
Call transform directly on the RDD instead.
:param vector: Vector or RDD of Vec... | python | def transform(self, vector):
"""
Applies transformation on a vector or an RDD[Vector].
.. note:: In Python, transform cannot currently be used within
an RDD transformation or action.
Call transform directly on the RDD instead.
:param vector: Vector or RDD of Vec... | [
"def",
"transform",
"(",
"self",
",",
"vector",
")",
":",
"if",
"isinstance",
"(",
"vector",
",",
"RDD",
")",
":",
"vector",
"=",
"vector",
".",
"map",
"(",
"_convert_to_vector",
")",
"else",
":",
"vector",
"=",
"_convert_to_vector",
"(",
"vector",
")",
... | Applies transformation on a vector or an RDD[Vector].
.. note:: In Python, transform cannot currently be used within
an RDD transformation or action.
Call transform directly on the RDD instead.
:param vector: Vector or RDD of Vector to be transformed. | [
"Applies",
"transformation",
"on",
"a",
"vector",
"or",
"an",
"RDD",
"[",
"Vector",
"]",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/feature.py#L111-L125 | train |
apache/spark | python/pyspark/mllib/feature.py | StandardScaler.fit | def fit(self, dataset):
"""
Computes the mean and variance and stores as a model to be used
for later scaling.
:param dataset: The data used to compute the mean and variance
to build the transformation model.
:return: a StandardScalarModel
"""
... | python | def fit(self, dataset):
"""
Computes the mean and variance and stores as a model to be used
for later scaling.
:param dataset: The data used to compute the mean and variance
to build the transformation model.
:return: a StandardScalarModel
"""
... | [
"def",
"fit",
"(",
"self",
",",
"dataset",
")",
":",
"dataset",
"=",
"dataset",
".",
"map",
"(",
"_convert_to_vector",
")",
"jmodel",
"=",
"callMLlibFunc",
"(",
"\"fitStandardScaler\"",
",",
"self",
".",
"withMean",
",",
"self",
".",
"withStd",
",",
"datas... | Computes the mean and variance and stores as a model to be used
for later scaling.
:param dataset: The data used to compute the mean and variance
to build the transformation model.
:return: a StandardScalarModel | [
"Computes",
"the",
"mean",
"and",
"variance",
"and",
"stores",
"as",
"a",
"model",
"to",
"be",
"used",
"for",
"later",
"scaling",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/feature.py#L240-L251 | train |
apache/spark | python/pyspark/mllib/feature.py | ChiSqSelector.fit | def fit(self, data):
"""
Returns a ChiSquared feature selector.
:param data: an `RDD[LabeledPoint]` containing the labeled dataset
with categorical features. Real-valued features will be
treated as categorical for each distinct value.
... | python | def fit(self, data):
"""
Returns a ChiSquared feature selector.
:param data: an `RDD[LabeledPoint]` containing the labeled dataset
with categorical features. Real-valued features will be
treated as categorical for each distinct value.
... | [
"def",
"fit",
"(",
"self",
",",
"data",
")",
":",
"jmodel",
"=",
"callMLlibFunc",
"(",
"\"fitChiSqSelector\"",
",",
"self",
".",
"selectorType",
",",
"self",
".",
"numTopFeatures",
",",
"self",
".",
"percentile",
",",
"self",
".",
"fpr",
",",
"self",
"."... | Returns a ChiSquared feature selector.
:param data: an `RDD[LabeledPoint]` containing the labeled dataset
with categorical features. Real-valued features will be
treated as categorical for each distinct value.
Apply feature discretizer before using... | [
"Returns",
"a",
"ChiSquared",
"feature",
"selector",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/feature.py#L383-L394 | train |
apache/spark | python/pyspark/mllib/feature.py | PCA.fit | def fit(self, data):
"""
Computes a [[PCAModel]] that contains the principal components of the input vectors.
:param data: source vectors
"""
jmodel = callMLlibFunc("fitPCA", self.k, data)
return PCAModel(jmodel) | python | def fit(self, data):
"""
Computes a [[PCAModel]] that contains the principal components of the input vectors.
:param data: source vectors
"""
jmodel = callMLlibFunc("fitPCA", self.k, data)
return PCAModel(jmodel) | [
"def",
"fit",
"(",
"self",
",",
"data",
")",
":",
"jmodel",
"=",
"callMLlibFunc",
"(",
"\"fitPCA\"",
",",
"self",
".",
"k",
",",
"data",
")",
"return",
"PCAModel",
"(",
"jmodel",
")"
] | Computes a [[PCAModel]] that contains the principal components of the input vectors.
:param data: source vectors | [
"Computes",
"a",
"[[",
"PCAModel",
"]]",
"that",
"contains",
"the",
"principal",
"components",
"of",
"the",
"input",
"vectors",
".",
":",
"param",
"data",
":",
"source",
"vectors"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/feature.py#L428-L434 | train |
apache/spark | python/pyspark/mllib/feature.py | HashingTF.transform | def transform(self, document):
"""
Transforms the input document (list of terms) to term frequency
vectors, or transform the RDD of document to RDD of term
frequency vectors.
"""
if isinstance(document, RDD):
return document.map(self.transform)
freq =... | python | def transform(self, document):
"""
Transforms the input document (list of terms) to term frequency
vectors, or transform the RDD of document to RDD of term
frequency vectors.
"""
if isinstance(document, RDD):
return document.map(self.transform)
freq =... | [
"def",
"transform",
"(",
"self",
",",
"document",
")",
":",
"if",
"isinstance",
"(",
"document",
",",
"RDD",
")",
":",
"return",
"document",
".",
"map",
"(",
"self",
".",
"transform",
")",
"freq",
"=",
"{",
"}",
"for",
"term",
"in",
"document",
":",
... | Transforms the input document (list of terms) to term frequency
vectors, or transform the RDD of document to RDD of term
frequency vectors. | [
"Transforms",
"the",
"input",
"document",
"(",
"list",
"of",
"terms",
")",
"to",
"term",
"frequency",
"vectors",
"or",
"transform",
"the",
"RDD",
"of",
"document",
"to",
"RDD",
"of",
"term",
"frequency",
"vectors",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/feature.py#L473-L486 | train |
apache/spark | python/pyspark/mllib/feature.py | IDF.fit | def fit(self, dataset):
"""
Computes the inverse document frequency.
:param dataset: an RDD of term frequency vectors
"""
if not isinstance(dataset, RDD):
raise TypeError("dataset should be an RDD of term frequency vectors")
jmodel = callMLlibFunc("fitIDF", s... | python | def fit(self, dataset):
"""
Computes the inverse document frequency.
:param dataset: an RDD of term frequency vectors
"""
if not isinstance(dataset, RDD):
raise TypeError("dataset should be an RDD of term frequency vectors")
jmodel = callMLlibFunc("fitIDF", s... | [
"def",
"fit",
"(",
"self",
",",
"dataset",
")",
":",
"if",
"not",
"isinstance",
"(",
"dataset",
",",
"RDD",
")",
":",
"raise",
"TypeError",
"(",
"\"dataset should be an RDD of term frequency vectors\"",
")",
"jmodel",
"=",
"callMLlibFunc",
"(",
"\"fitIDF\"",
","... | Computes the inverse document frequency.
:param dataset: an RDD of term frequency vectors | [
"Computes",
"the",
"inverse",
"document",
"frequency",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/feature.py#L577-L586 | train |
apache/spark | python/pyspark/mllib/feature.py | Word2VecModel.findSynonyms | def findSynonyms(self, word, num):
"""
Find synonyms of a word
:param word: a word or a vector representation of word
:param num: number of synonyms to find
:return: array of (word, cosineSimilarity)
.. note:: Local use only
"""
if not isinstance(word, b... | python | def findSynonyms(self, word, num):
"""
Find synonyms of a word
:param word: a word or a vector representation of word
:param num: number of synonyms to find
:return: array of (word, cosineSimilarity)
.. note:: Local use only
"""
if not isinstance(word, b... | [
"def",
"findSynonyms",
"(",
"self",
",",
"word",
",",
"num",
")",
":",
"if",
"not",
"isinstance",
"(",
"word",
",",
"basestring",
")",
":",
"word",
"=",
"_convert_to_vector",
"(",
"word",
")",
"words",
",",
"similarity",
"=",
"self",
".",
"call",
"(",
... | Find synonyms of a word
:param word: a word or a vector representation of word
:param num: number of synonyms to find
:return: array of (word, cosineSimilarity)
.. note:: Local use only | [
"Find",
"synonyms",
"of",
"a",
"word"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/feature.py#L611-L624 | train |
apache/spark | python/pyspark/mllib/feature.py | Word2VecModel.load | def load(cls, sc, path):
"""
Load a model from the given path.
"""
jmodel = sc._jvm.org.apache.spark.mllib.feature \
.Word2VecModel.load(sc._jsc.sc(), path)
model = sc._jvm.org.apache.spark.mllib.api.python.Word2VecModelWrapper(jmodel)
return Word2VecModel(mod... | python | def load(cls, sc, path):
"""
Load a model from the given path.
"""
jmodel = sc._jvm.org.apache.spark.mllib.feature \
.Word2VecModel.load(sc._jsc.sc(), path)
model = sc._jvm.org.apache.spark.mllib.api.python.Word2VecModelWrapper(jmodel)
return Word2VecModel(mod... | [
"def",
"load",
"(",
"cls",
",",
"sc",
",",
"path",
")",
":",
"jmodel",
"=",
"sc",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",
"mllib",
".",
"feature",
".",
"Word2VecModel",
".",
"load",
"(",
"sc",
".",
"_jsc",
".",
"sc",
"(",
")"... | Load a model from the given path. | [
"Load",
"a",
"model",
"from",
"the",
"given",
"path",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/feature.py#L635-L642 | train |
apache/spark | python/pyspark/mllib/feature.py | ElementwiseProduct.transform | def transform(self, vector):
"""
Computes the Hadamard product of the vector.
"""
if isinstance(vector, RDD):
vector = vector.map(_convert_to_vector)
else:
vector = _convert_to_vector(vector)
return callMLlibFunc("elementwiseProductVector", self.s... | python | def transform(self, vector):
"""
Computes the Hadamard product of the vector.
"""
if isinstance(vector, RDD):
vector = vector.map(_convert_to_vector)
else:
vector = _convert_to_vector(vector)
return callMLlibFunc("elementwiseProductVector", self.s... | [
"def",
"transform",
"(",
"self",
",",
"vector",
")",
":",
"if",
"isinstance",
"(",
"vector",
",",
"RDD",
")",
":",
"vector",
"=",
"vector",
".",
"map",
"(",
"_convert_to_vector",
")",
"else",
":",
"vector",
"=",
"_convert_to_vector",
"(",
"vector",
")",
... | Computes the Hadamard product of the vector. | [
"Computes",
"the",
"Hadamard",
"product",
"of",
"the",
"vector",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/feature.py#L810-L819 | train |
apache/spark | python/pyspark/mllib/tree.py | TreeEnsembleModel.predict | def predict(self, x):
"""
Predict values for a single data point or an RDD of points using
the model trained.
.. note:: In Python, predict cannot currently be used within an RDD
transformation or action.
Call predict directly on the RDD instead.
"""
... | python | def predict(self, x):
"""
Predict values for a single data point or an RDD of points using
the model trained.
.. note:: In Python, predict cannot currently be used within an RDD
transformation or action.
Call predict directly on the RDD instead.
"""
... | [
"def",
"predict",
"(",
"self",
",",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"RDD",
")",
":",
"return",
"self",
".",
"call",
"(",
"\"predict\"",
",",
"x",
".",
"map",
"(",
"_convert_to_vector",
")",
")",
"else",
":",
"return",
"self",
".",... | Predict values for a single data point or an RDD of points using
the model trained.
.. note:: In Python, predict cannot currently be used within an RDD
transformation or action.
Call predict directly on the RDD instead. | [
"Predict",
"values",
"for",
"a",
"single",
"data",
"point",
"or",
"an",
"RDD",
"of",
"points",
"using",
"the",
"model",
"trained",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/tree.py#L39-L52 | train |
apache/spark | python/pyspark/mllib/tree.py | DecisionTree.trainClassifier | def trainClassifier(cls, data, numClasses, categoricalFeaturesInfo,
impurity="gini", maxDepth=5, maxBins=32, minInstancesPerNode=1,
minInfoGain=0.0):
"""
Train a decision tree model for classification.
:param data:
Training data: RDD of ... | python | def trainClassifier(cls, data, numClasses, categoricalFeaturesInfo,
impurity="gini", maxDepth=5, maxBins=32, minInstancesPerNode=1,
minInfoGain=0.0):
"""
Train a decision tree model for classification.
:param data:
Training data: RDD of ... | [
"def",
"trainClassifier",
"(",
"cls",
",",
"data",
",",
"numClasses",
",",
"categoricalFeaturesInfo",
",",
"impurity",
"=",
"\"gini\"",
",",
"maxDepth",
"=",
"5",
",",
"maxBins",
"=",
"32",
",",
"minInstancesPerNode",
"=",
"1",
",",
"minInfoGain",
"=",
"0.0"... | Train a decision tree model for classification.
:param data:
Training data: RDD of LabeledPoint. Labels should take values
{0, 1, ..., numClasses-1}.
:param numClasses:
Number of classes for classification.
:param categoricalFeaturesInfo:
Map storing arit... | [
"Train",
"a",
"decision",
"tree",
"model",
"for",
"classification",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/tree.py#L149-L217 | train |
apache/spark | python/pyspark/mllib/tree.py | DecisionTree.trainRegressor | def trainRegressor(cls, data, categoricalFeaturesInfo,
impurity="variance", maxDepth=5, maxBins=32, minInstancesPerNode=1,
minInfoGain=0.0):
"""
Train a decision tree model for regression.
:param data:
Training data: RDD of LabeledPoint. L... | python | def trainRegressor(cls, data, categoricalFeaturesInfo,
impurity="variance", maxDepth=5, maxBins=32, minInstancesPerNode=1,
minInfoGain=0.0):
"""
Train a decision tree model for regression.
:param data:
Training data: RDD of LabeledPoint. L... | [
"def",
"trainRegressor",
"(",
"cls",
",",
"data",
",",
"categoricalFeaturesInfo",
",",
"impurity",
"=",
"\"variance\"",
",",
"maxDepth",
"=",
"5",
",",
"maxBins",
"=",
"32",
",",
"minInstancesPerNode",
"=",
"1",
",",
"minInfoGain",
"=",
"0.0",
")",
":",
"r... | Train a decision tree model for regression.
:param data:
Training data: RDD of LabeledPoint. Labels are real numbers.
:param categoricalFeaturesInfo:
Map storing arity of categorical features. An entry (n -> k)
indicates that feature n is categorical with k categories
... | [
"Train",
"a",
"decision",
"tree",
"model",
"for",
"regression",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/tree.py#L221-L277 | train |
apache/spark | python/pyspark/mllib/tree.py | RandomForest.trainClassifier | def trainClassifier(cls, data, numClasses, categoricalFeaturesInfo, numTrees,
featureSubsetStrategy="auto", impurity="gini", maxDepth=4, maxBins=32,
seed=None):
"""
Train a random forest model for binary or multiclass
classification.
:para... | python | def trainClassifier(cls, data, numClasses, categoricalFeaturesInfo, numTrees,
featureSubsetStrategy="auto", impurity="gini", maxDepth=4, maxBins=32,
seed=None):
"""
Train a random forest model for binary or multiclass
classification.
:para... | [
"def",
"trainClassifier",
"(",
"cls",
",",
"data",
",",
"numClasses",
",",
"categoricalFeaturesInfo",
",",
"numTrees",
",",
"featureSubsetStrategy",
"=",
"\"auto\"",
",",
"impurity",
"=",
"\"gini\"",
",",
"maxDepth",
"=",
"4",
",",
"maxBins",
"=",
"32",
",",
... | Train a random forest model for binary or multiclass
classification.
:param data:
Training dataset: RDD of LabeledPoint. Labels should take values
{0, 1, ..., numClasses-1}.
:param numClasses:
Number of classes for classification.
:param categoricalFeatures... | [
"Train",
"a",
"random",
"forest",
"model",
"for",
"binary",
"or",
"multiclass",
"classification",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/tree.py#L319-L407 | train |
apache/spark | python/pyspark/mllib/tree.py | RandomForest.trainRegressor | def trainRegressor(cls, data, categoricalFeaturesInfo, numTrees, featureSubsetStrategy="auto",
impurity="variance", maxDepth=4, maxBins=32, seed=None):
"""
Train a random forest model for regression.
:param data:
Training dataset: RDD of LabeledPoint. Labels are... | python | def trainRegressor(cls, data, categoricalFeaturesInfo, numTrees, featureSubsetStrategy="auto",
impurity="variance", maxDepth=4, maxBins=32, seed=None):
"""
Train a random forest model for regression.
:param data:
Training dataset: RDD of LabeledPoint. Labels are... | [
"def",
"trainRegressor",
"(",
"cls",
",",
"data",
",",
"categoricalFeaturesInfo",
",",
"numTrees",
",",
"featureSubsetStrategy",
"=",
"\"auto\"",
",",
"impurity",
"=",
"\"variance\"",
",",
"maxDepth",
"=",
"4",
",",
"maxBins",
"=",
"32",
",",
"seed",
"=",
"N... | Train a random forest model for regression.
:param data:
Training dataset: RDD of LabeledPoint. Labels are real numbers.
:param categoricalFeaturesInfo:
Map storing arity of categorical features. An entry (n -> k)
indicates that feature n is categorical with k categories
... | [
"Train",
"a",
"random",
"forest",
"model",
"for",
"regression",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/tree.py#L411-L476 | train |
apache/spark | python/pyspark/mllib/tree.py | GradientBoostedTrees.trainClassifier | def trainClassifier(cls, data, categoricalFeaturesInfo,
loss="logLoss", numIterations=100, learningRate=0.1, maxDepth=3,
maxBins=32):
"""
Train a gradient-boosted trees model for classification.
:param data:
Training dataset: RDD of Labe... | python | def trainClassifier(cls, data, categoricalFeaturesInfo,
loss="logLoss", numIterations=100, learningRate=0.1, maxDepth=3,
maxBins=32):
"""
Train a gradient-boosted trees model for classification.
:param data:
Training dataset: RDD of Labe... | [
"def",
"trainClassifier",
"(",
"cls",
",",
"data",
",",
"categoricalFeaturesInfo",
",",
"loss",
"=",
"\"logLoss\"",
",",
"numIterations",
"=",
"100",
",",
"learningRate",
"=",
"0.1",
",",
"maxDepth",
"=",
"3",
",",
"maxBins",
"=",
"32",
")",
":",
"return",... | Train a gradient-boosted trees model for classification.
:param data:
Training dataset: RDD of LabeledPoint. Labels should take values
{0, 1}.
:param categoricalFeaturesInfo:
Map storing arity of categorical features. An entry (n -> k)
indicates that feature n is... | [
"Train",
"a",
"gradient",
"-",
"boosted",
"trees",
"model",
"for",
"classification",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/tree.py#L511-L576 | train |
apache/spark | python/pyspark/conf.py | SparkConf.set | def set(self, key, value):
"""Set a configuration property."""
# Try to set self._jconf first if JVM is created, set self._conf if JVM is not created yet.
if self._jconf is not None:
self._jconf.set(key, unicode(value))
else:
self._conf[key] = unicode(value)
... | python | def set(self, key, value):
"""Set a configuration property."""
# Try to set self._jconf first if JVM is created, set self._conf if JVM is not created yet.
if self._jconf is not None:
self._jconf.set(key, unicode(value))
else:
self._conf[key] = unicode(value)
... | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"# Try to set self._jconf first if JVM is created, set self._conf if JVM is not created yet.",
"if",
"self",
".",
"_jconf",
"is",
"not",
"None",
":",
"self",
".",
"_jconf",
".",
"set",
"(",
"key",
",",... | Set a configuration property. | [
"Set",
"a",
"configuration",
"property",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/conf.py#L123-L130 | train |
apache/spark | python/pyspark/conf.py | SparkConf.setIfMissing | def setIfMissing(self, key, value):
"""Set a configuration property, if not already set."""
if self.get(key) is None:
self.set(key, value)
return self | python | def setIfMissing(self, key, value):
"""Set a configuration property, if not already set."""
if self.get(key) is None:
self.set(key, value)
return self | [
"def",
"setIfMissing",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"self",
".",
"get",
"(",
"key",
")",
"is",
"None",
":",
"self",
".",
"set",
"(",
"key",
",",
"value",
")",
"return",
"self"
] | Set a configuration property, if not already set. | [
"Set",
"a",
"configuration",
"property",
"if",
"not",
"already",
"set",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/conf.py#L132-L136 | train |
apache/spark | python/pyspark/conf.py | SparkConf.setExecutorEnv | def setExecutorEnv(self, key=None, value=None, pairs=None):
"""Set an environment variable to be passed to executors."""
if (key is not None and pairs is not None) or (key is None and pairs is None):
raise Exception("Either pass one key-value pair or a list of pairs")
elif key is not... | python | def setExecutorEnv(self, key=None, value=None, pairs=None):
"""Set an environment variable to be passed to executors."""
if (key is not None and pairs is not None) or (key is None and pairs is None):
raise Exception("Either pass one key-value pair or a list of pairs")
elif key is not... | [
"def",
"setExecutorEnv",
"(",
"self",
",",
"key",
"=",
"None",
",",
"value",
"=",
"None",
",",
"pairs",
"=",
"None",
")",
":",
"if",
"(",
"key",
"is",
"not",
"None",
"and",
"pairs",
"is",
"not",
"None",
")",
"or",
"(",
"key",
"is",
"None",
"and",... | Set an environment variable to be passed to executors. | [
"Set",
"an",
"environment",
"variable",
"to",
"be",
"passed",
"to",
"executors",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/conf.py#L153-L162 | train |
apache/spark | python/pyspark/conf.py | SparkConf.setAll | def setAll(self, pairs):
"""
Set multiple parameters, passed as a list of key-value pairs.
:param pairs: list of key-value pairs to set
"""
for (k, v) in pairs:
self.set(k, v)
return self | python | def setAll(self, pairs):
"""
Set multiple parameters, passed as a list of key-value pairs.
:param pairs: list of key-value pairs to set
"""
for (k, v) in pairs:
self.set(k, v)
return self | [
"def",
"setAll",
"(",
"self",
",",
"pairs",
")",
":",
"for",
"(",
"k",
",",
"v",
")",
"in",
"pairs",
":",
"self",
".",
"set",
"(",
"k",
",",
"v",
")",
"return",
"self"
] | Set multiple parameters, passed as a list of key-value pairs.
:param pairs: list of key-value pairs to set | [
"Set",
"multiple",
"parameters",
"passed",
"as",
"a",
"list",
"of",
"key",
"-",
"value",
"pairs",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/conf.py#L164-L172 | train |
apache/spark | python/pyspark/conf.py | SparkConf.get | def get(self, key, defaultValue=None):
"""Get the configured value for some key, or return a default otherwise."""
if defaultValue is None: # Py4J doesn't call the right get() if we pass None
if self._jconf is not None:
if not self._jconf.contains(key):
... | python | def get(self, key, defaultValue=None):
"""Get the configured value for some key, or return a default otherwise."""
if defaultValue is None: # Py4J doesn't call the right get() if we pass None
if self._jconf is not None:
if not self._jconf.contains(key):
... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"defaultValue",
"=",
"None",
")",
":",
"if",
"defaultValue",
"is",
"None",
":",
"# Py4J doesn't call the right get() if we pass None",
"if",
"self",
".",
"_jconf",
"is",
"not",
"None",
":",
"if",
"not",
"self",
"."... | Get the configured value for some key, or return a default otherwise. | [
"Get",
"the",
"configured",
"value",
"for",
"some",
"key",
"or",
"return",
"a",
"default",
"otherwise",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/conf.py#L174-L189 | train |
apache/spark | python/pyspark/conf.py | SparkConf.getAll | def getAll(self):
"""Get all values as a list of key-value pairs."""
if self._jconf is not None:
return [(elem._1(), elem._2()) for elem in self._jconf.getAll()]
else:
return self._conf.items() | python | def getAll(self):
"""Get all values as a list of key-value pairs."""
if self._jconf is not None:
return [(elem._1(), elem._2()) for elem in self._jconf.getAll()]
else:
return self._conf.items() | [
"def",
"getAll",
"(",
"self",
")",
":",
"if",
"self",
".",
"_jconf",
"is",
"not",
"None",
":",
"return",
"[",
"(",
"elem",
".",
"_1",
"(",
")",
",",
"elem",
".",
"_2",
"(",
")",
")",
"for",
"elem",
"in",
"self",
".",
"_jconf",
".",
"getAll",
... | Get all values as a list of key-value pairs. | [
"Get",
"all",
"values",
"as",
"a",
"list",
"of",
"key",
"-",
"value",
"pairs",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/conf.py#L191-L196 | train |
apache/spark | python/pyspark/conf.py | SparkConf.contains | def contains(self, key):
"""Does this configuration contain a given key?"""
if self._jconf is not None:
return self._jconf.contains(key)
else:
return key in self._conf | python | def contains(self, key):
"""Does this configuration contain a given key?"""
if self._jconf is not None:
return self._jconf.contains(key)
else:
return key in self._conf | [
"def",
"contains",
"(",
"self",
",",
"key",
")",
":",
"if",
"self",
".",
"_jconf",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_jconf",
".",
"contains",
"(",
"key",
")",
"else",
":",
"return",
"key",
"in",
"self",
".",
"_conf"
] | Does this configuration contain a given key? | [
"Does",
"this",
"configuration",
"contain",
"a",
"given",
"key?"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/conf.py#L198-L203 | train |
apache/spark | python/pyspark/conf.py | SparkConf.toDebugString | def toDebugString(self):
"""
Returns a printable version of the configuration, as a list of
key=value pairs, one per line.
"""
if self._jconf is not None:
return self._jconf.toDebugString()
else:
return '\n'.join('%s=%s' % (k, v) for k, v in self._... | python | def toDebugString(self):
"""
Returns a printable version of the configuration, as a list of
key=value pairs, one per line.
"""
if self._jconf is not None:
return self._jconf.toDebugString()
else:
return '\n'.join('%s=%s' % (k, v) for k, v in self._... | [
"def",
"toDebugString",
"(",
"self",
")",
":",
"if",
"self",
".",
"_jconf",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_jconf",
".",
"toDebugString",
"(",
")",
"else",
":",
"return",
"'\\n'",
".",
"join",
"(",
"'%s=%s'",
"%",
"(",
"k",
",",
... | Returns a printable version of the configuration, as a list of
key=value pairs, one per line. | [
"Returns",
"a",
"printable",
"version",
"of",
"the",
"configuration",
"as",
"a",
"list",
"of",
"key",
"=",
"value",
"pairs",
"one",
"per",
"line",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/conf.py#L205-L213 | train |
apache/spark | python/pyspark/sql/catalog.py | Catalog.listDatabases | def listDatabases(self):
"""Returns a list of databases available across all sessions."""
iter = self._jcatalog.listDatabases().toLocalIterator()
databases = []
while iter.hasNext():
jdb = iter.next()
databases.append(Database(
name=jdb.name(),
... | python | def listDatabases(self):
"""Returns a list of databases available across all sessions."""
iter = self._jcatalog.listDatabases().toLocalIterator()
databases = []
while iter.hasNext():
jdb = iter.next()
databases.append(Database(
name=jdb.name(),
... | [
"def",
"listDatabases",
"(",
"self",
")",
":",
"iter",
"=",
"self",
".",
"_jcatalog",
".",
"listDatabases",
"(",
")",
".",
"toLocalIterator",
"(",
")",
"databases",
"=",
"[",
"]",
"while",
"iter",
".",
"hasNext",
"(",
")",
":",
"jdb",
"=",
"iter",
".... | Returns a list of databases available across all sessions. | [
"Returns",
"a",
"list",
"of",
"databases",
"available",
"across",
"all",
"sessions",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/catalog.py#L61-L71 | train |
apache/spark | python/pyspark/sql/catalog.py | Catalog.listTables | def listTables(self, dbName=None):
"""Returns a list of tables/views in the specified database.
If no database is specified, the current database is used.
This includes all temporary views.
"""
if dbName is None:
dbName = self.currentDatabase()
iter = self._j... | python | def listTables(self, dbName=None):
"""Returns a list of tables/views in the specified database.
If no database is specified, the current database is used.
This includes all temporary views.
"""
if dbName is None:
dbName = self.currentDatabase()
iter = self._j... | [
"def",
"listTables",
"(",
"self",
",",
"dbName",
"=",
"None",
")",
":",
"if",
"dbName",
"is",
"None",
":",
"dbName",
"=",
"self",
".",
"currentDatabase",
"(",
")",
"iter",
"=",
"self",
".",
"_jcatalog",
".",
"listTables",
"(",
"dbName",
")",
".",
"to... | Returns a list of tables/views in the specified database.
If no database is specified, the current database is used.
This includes all temporary views. | [
"Returns",
"a",
"list",
"of",
"tables",
"/",
"views",
"in",
"the",
"specified",
"database",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/catalog.py#L75-L93 | train |
apache/spark | python/pyspark/sql/catalog.py | Catalog.listFunctions | def listFunctions(self, dbName=None):
"""Returns a list of functions registered in the specified database.
If no database is specified, the current database is used.
This includes all temporary functions.
"""
if dbName is None:
dbName = self.currentDatabase()
... | python | def listFunctions(self, dbName=None):
"""Returns a list of functions registered in the specified database.
If no database is specified, the current database is used.
This includes all temporary functions.
"""
if dbName is None:
dbName = self.currentDatabase()
... | [
"def",
"listFunctions",
"(",
"self",
",",
"dbName",
"=",
"None",
")",
":",
"if",
"dbName",
"is",
"None",
":",
"dbName",
"=",
"self",
".",
"currentDatabase",
"(",
")",
"iter",
"=",
"self",
".",
"_jcatalog",
".",
"listFunctions",
"(",
"dbName",
")",
".",... | Returns a list of functions registered in the specified database.
If no database is specified, the current database is used.
This includes all temporary functions. | [
"Returns",
"a",
"list",
"of",
"functions",
"registered",
"in",
"the",
"specified",
"database",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/catalog.py#L97-L114 | train |
apache/spark | python/pyspark/sql/catalog.py | Catalog.listColumns | def listColumns(self, tableName, dbName=None):
"""Returns a list of columns for the given table/view in the specified database.
If no database is specified, the current database is used.
Note: the order of arguments here is different from that of its JVM counterpart
because Python does... | python | def listColumns(self, tableName, dbName=None):
"""Returns a list of columns for the given table/view in the specified database.
If no database is specified, the current database is used.
Note: the order of arguments here is different from that of its JVM counterpart
because Python does... | [
"def",
"listColumns",
"(",
"self",
",",
"tableName",
",",
"dbName",
"=",
"None",
")",
":",
"if",
"dbName",
"is",
"None",
":",
"dbName",
"=",
"self",
".",
"currentDatabase",
"(",
")",
"iter",
"=",
"self",
".",
"_jcatalog",
".",
"listColumns",
"(",
"dbNa... | Returns a list of columns for the given table/view in the specified database.
If no database is specified, the current database is used.
Note: the order of arguments here is different from that of its JVM counterpart
because Python does not support method overloading. | [
"Returns",
"a",
"list",
"of",
"columns",
"for",
"the",
"given",
"table",
"/",
"view",
"in",
"the",
"specified",
"database",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/catalog.py#L118-L139 | train |
apache/spark | python/pyspark/sql/catalog.py | Catalog.createExternalTable | def createExternalTable(self, tableName, path=None, source=None, schema=None, **options):
"""Creates a table based on the dataset in a data source.
It returns the DataFrame associated with the external table.
The data source is specified by the ``source`` and a set of ``options``.
If `... | python | def createExternalTable(self, tableName, path=None, source=None, schema=None, **options):
"""Creates a table based on the dataset in a data source.
It returns the DataFrame associated with the external table.
The data source is specified by the ``source`` and a set of ``options``.
If `... | [
"def",
"createExternalTable",
"(",
"self",
",",
"tableName",
",",
"path",
"=",
"None",
",",
"source",
"=",
"None",
",",
"schema",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"warnings",
".",
"warn",
"(",
"\"createExternalTable is deprecated since Spark 2.... | Creates a table based on the dataset in a data source.
It returns the DataFrame associated with the external table.
The data source is specified by the ``source`` and a set of ``options``.
If ``source`` is not specified, the default data source configured by
``spark.sql.sources.default... | [
"Creates",
"a",
"table",
"based",
"on",
"the",
"dataset",
"in",
"a",
"data",
"source",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/catalog.py#L142-L159 | train |
apache/spark | python/pyspark/sql/catalog.py | Catalog.createTable | def createTable(self, tableName, path=None, source=None, schema=None, **options):
"""Creates a table based on the dataset in a data source.
It returns the DataFrame associated with the table.
The data source is specified by the ``source`` and a set of ``options``.
If ``source`` is not ... | python | def createTable(self, tableName, path=None, source=None, schema=None, **options):
"""Creates a table based on the dataset in a data source.
It returns the DataFrame associated with the table.
The data source is specified by the ``source`` and a set of ``options``.
If ``source`` is not ... | [
"def",
"createTable",
"(",
"self",
",",
"tableName",
",",
"path",
"=",
"None",
",",
"source",
"=",
"None",
",",
"schema",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"if",
"path",
"is",
"not",
"None",
":",
"options",
"[",
"\"path\"",
"]",
"=",... | Creates a table based on the dataset in a data source.
It returns the DataFrame associated with the table.
The data source is specified by the ``source`` and a set of ``options``.
If ``source`` is not specified, the default data source configured by
``spark.sql.sources.default`` will b... | [
"Creates",
"a",
"table",
"based",
"on",
"the",
"dataset",
"in",
"a",
"data",
"source",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/catalog.py#L162-L188 | train |
apache/spark | python/pyspark/taskcontext.py | _load_from_socket | def _load_from_socket(port, auth_secret):
"""
Load data from a given socket, this is a blocking method thus only return when the socket
connection has been closed.
"""
(sockfile, sock) = local_connect_and_auth(port, auth_secret)
# The barrier() call may block forever, so no timeout
sock.sett... | python | def _load_from_socket(port, auth_secret):
"""
Load data from a given socket, this is a blocking method thus only return when the socket
connection has been closed.
"""
(sockfile, sock) = local_connect_and_auth(port, auth_secret)
# The barrier() call may block forever, so no timeout
sock.sett... | [
"def",
"_load_from_socket",
"(",
"port",
",",
"auth_secret",
")",
":",
"(",
"sockfile",
",",
"sock",
")",
"=",
"local_connect_and_auth",
"(",
"port",
",",
"auth_secret",
")",
"# The barrier() call may block forever, so no timeout",
"sock",
".",
"settimeout",
"(",
"N... | Load data from a given socket, this is a blocking method thus only return when the socket
connection has been closed. | [
"Load",
"data",
"from",
"a",
"given",
"socket",
"this",
"is",
"a",
"blocking",
"method",
"thus",
"only",
"return",
"when",
"the",
"socket",
"connection",
"has",
"been",
"closed",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/taskcontext.py#L102-L121 | train |
apache/spark | python/pyspark/taskcontext.py | BarrierTaskContext._getOrCreate | def _getOrCreate(cls):
"""
Internal function to get or create global BarrierTaskContext. We need to make sure
BarrierTaskContext is returned from here because it is needed in python worker reuse
scenario, see SPARK-25921 for more details.
"""
if not isinstance(cls._taskCo... | python | def _getOrCreate(cls):
"""
Internal function to get or create global BarrierTaskContext. We need to make sure
BarrierTaskContext is returned from here because it is needed in python worker reuse
scenario, see SPARK-25921 for more details.
"""
if not isinstance(cls._taskCo... | [
"def",
"_getOrCreate",
"(",
"cls",
")",
":",
"if",
"not",
"isinstance",
"(",
"cls",
".",
"_taskContext",
",",
"BarrierTaskContext",
")",
":",
"cls",
".",
"_taskContext",
"=",
"object",
".",
"__new__",
"(",
"cls",
")",
"return",
"cls",
".",
"_taskContext"
] | Internal function to get or create global BarrierTaskContext. We need to make sure
BarrierTaskContext is returned from here because it is needed in python worker reuse
scenario, see SPARK-25921 for more details. | [
"Internal",
"function",
"to",
"get",
"or",
"create",
"global",
"BarrierTaskContext",
".",
"We",
"need",
"to",
"make",
"sure",
"BarrierTaskContext",
"is",
"returned",
"from",
"here",
"because",
"it",
"is",
"needed",
"in",
"python",
"worker",
"reuse",
"scenario",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/taskcontext.py#L139-L147 | train |
apache/spark | python/pyspark/taskcontext.py | BarrierTaskContext._initialize | def _initialize(cls, port, secret):
"""
Initialize BarrierTaskContext, other methods within BarrierTaskContext can only be called
after BarrierTaskContext is initialized.
"""
cls._port = port
cls._secret = secret | python | def _initialize(cls, port, secret):
"""
Initialize BarrierTaskContext, other methods within BarrierTaskContext can only be called
after BarrierTaskContext is initialized.
"""
cls._port = port
cls._secret = secret | [
"def",
"_initialize",
"(",
"cls",
",",
"port",
",",
"secret",
")",
":",
"cls",
".",
"_port",
"=",
"port",
"cls",
".",
"_secret",
"=",
"secret"
] | Initialize BarrierTaskContext, other methods within BarrierTaskContext can only be called
after BarrierTaskContext is initialized. | [
"Initialize",
"BarrierTaskContext",
"other",
"methods",
"within",
"BarrierTaskContext",
"can",
"only",
"be",
"called",
"after",
"BarrierTaskContext",
"is",
"initialized",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/taskcontext.py#L163-L169 | train |
apache/spark | python/pyspark/taskcontext.py | BarrierTaskContext.barrier | def barrier(self):
"""
.. note:: Experimental
Sets a global barrier and waits until all tasks in this stage hit this barrier.
Similar to `MPI_Barrier` function in MPI, this function blocks until all tasks
in the same stage have reached this routine.
.. warning:: In a ba... | python | def barrier(self):
"""
.. note:: Experimental
Sets a global barrier and waits until all tasks in this stage hit this barrier.
Similar to `MPI_Barrier` function in MPI, this function blocks until all tasks
in the same stage have reached this routine.
.. warning:: In a ba... | [
"def",
"barrier",
"(",
"self",
")",
":",
"if",
"self",
".",
"_port",
"is",
"None",
"or",
"self",
".",
"_secret",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"Not supported to call barrier() before initialize \"",
"+",
"\"BarrierTaskContext.\"",
")",
"else",
... | .. note:: Experimental
Sets a global barrier and waits until all tasks in this stage hit this barrier.
Similar to `MPI_Barrier` function in MPI, this function blocks until all tasks
in the same stage have reached this routine.
.. warning:: In a barrier stage, each task much have the sa... | [
"..",
"note",
"::",
"Experimental"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/taskcontext.py#L171-L189 | train |
apache/spark | python/pyspark/taskcontext.py | BarrierTaskContext.getTaskInfos | def getTaskInfos(self):
"""
.. note:: Experimental
Returns :class:`BarrierTaskInfo` for all tasks in this barrier stage,
ordered by partition ID.
.. versionadded:: 2.4.0
"""
if self._port is None or self._secret is None:
raise Exception("Not supporte... | python | def getTaskInfos(self):
"""
.. note:: Experimental
Returns :class:`BarrierTaskInfo` for all tasks in this barrier stage,
ordered by partition ID.
.. versionadded:: 2.4.0
"""
if self._port is None or self._secret is None:
raise Exception("Not supporte... | [
"def",
"getTaskInfos",
"(",
"self",
")",
":",
"if",
"self",
".",
"_port",
"is",
"None",
"or",
"self",
".",
"_secret",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"Not supported to call getTaskInfos() before initialize \"",
"+",
"\"BarrierTaskContext.\"",
")",
... | .. note:: Experimental
Returns :class:`BarrierTaskInfo` for all tasks in this barrier stage,
ordered by partition ID.
.. versionadded:: 2.4.0 | [
"..",
"note",
"::",
"Experimental"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/taskcontext.py#L191-L205 | train |
apache/spark | python/pyspark/__init__.py | since | def since(version):
"""
A decorator that annotates a function to append the version of Spark the function was added.
"""
import re
indent_p = re.compile(r'\n( +)')
def deco(f):
indents = indent_p.findall(f.__doc__)
indent = ' ' * (min(len(m) for m in indents) if indents else 0)
... | python | def since(version):
"""
A decorator that annotates a function to append the version of Spark the function was added.
"""
import re
indent_p = re.compile(r'\n( +)')
def deco(f):
indents = indent_p.findall(f.__doc__)
indent = ' ' * (min(len(m) for m in indents) if indents else 0)
... | [
"def",
"since",
"(",
"version",
")",
":",
"import",
"re",
"indent_p",
"=",
"re",
".",
"compile",
"(",
"r'\\n( +)'",
")",
"def",
"deco",
"(",
"f",
")",
":",
"indents",
"=",
"indent_p",
".",
"findall",
"(",
"f",
".",
"__doc__",
")",
"indent",
"=",
"'... | A decorator that annotates a function to append the version of Spark the function was added. | [
"A",
"decorator",
"that",
"annotates",
"a",
"function",
"to",
"append",
"the",
"version",
"of",
"Spark",
"the",
"function",
"was",
"added",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/__init__.py#L65-L77 | train |
apache/spark | python/pyspark/__init__.py | copy_func | def copy_func(f, name=None, sinceversion=None, doc=None):
"""
Returns a function with same code, globals, defaults, closure, and
name (or provide a new name).
"""
# See
# http://stackoverflow.com/questions/6527633/how-can-i-make-a-deepcopy-of-a-function-in-python
fn = types.FunctionType(f.__... | python | def copy_func(f, name=None, sinceversion=None, doc=None):
"""
Returns a function with same code, globals, defaults, closure, and
name (or provide a new name).
"""
# See
# http://stackoverflow.com/questions/6527633/how-can-i-make-a-deepcopy-of-a-function-in-python
fn = types.FunctionType(f.__... | [
"def",
"copy_func",
"(",
"f",
",",
"name",
"=",
"None",
",",
"sinceversion",
"=",
"None",
",",
"doc",
"=",
"None",
")",
":",
"# See",
"# http://stackoverflow.com/questions/6527633/how-can-i-make-a-deepcopy-of-a-function-in-python",
"fn",
"=",
"types",
".",
"FunctionTy... | Returns a function with same code, globals, defaults, closure, and
name (or provide a new name). | [
"Returns",
"a",
"function",
"with",
"same",
"code",
"globals",
"defaults",
"closure",
"and",
"name",
"(",
"or",
"provide",
"a",
"new",
"name",
")",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/__init__.py#L80-L95 | train |
apache/spark | python/pyspark/__init__.py | keyword_only | def keyword_only(func):
"""
A decorator that forces keyword arguments in the wrapped method
and saves actual input keyword arguments in `_input_kwargs`.
.. note:: Should only be used to wrap a method where first arg is `self`
"""
@wraps(func)
def wrapper(self, *args, **kwargs):
if l... | python | def keyword_only(func):
"""
A decorator that forces keyword arguments in the wrapped method
and saves actual input keyword arguments in `_input_kwargs`.
.. note:: Should only be used to wrap a method where first arg is `self`
"""
@wraps(func)
def wrapper(self, *args, **kwargs):
if l... | [
"def",
"keyword_only",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
">",
"0",
":",
"raise",
"TypeError",
"(",
"\"Method %... | A decorator that forces keyword arguments in the wrapped method
and saves actual input keyword arguments in `_input_kwargs`.
.. note:: Should only be used to wrap a method where first arg is `self` | [
"A",
"decorator",
"that",
"forces",
"keyword",
"arguments",
"in",
"the",
"wrapped",
"method",
"and",
"saves",
"actual",
"input",
"keyword",
"arguments",
"in",
"_input_kwargs",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/__init__.py#L98-L111 | train |
apache/spark | python/pyspark/ml/param/_shared_params_code_gen.py | _gen_param_header | def _gen_param_header(name, doc, defaultValueStr, typeConverter):
"""
Generates the header part for shared variables
:param name: param name
:param doc: param doc
"""
template = '''class Has$Name(Params):
"""
Mixin for param $name: $doc
"""
$name = Param(Params._dummy(), "$name... | python | def _gen_param_header(name, doc, defaultValueStr, typeConverter):
"""
Generates the header part for shared variables
:param name: param name
:param doc: param doc
"""
template = '''class Has$Name(Params):
"""
Mixin for param $name: $doc
"""
$name = Param(Params._dummy(), "$name... | [
"def",
"_gen_param_header",
"(",
"name",
",",
"doc",
",",
"defaultValueStr",
",",
"typeConverter",
")",
":",
"template",
"=",
"'''class Has$Name(Params):\n \"\"\"\n Mixin for param $name: $doc\n \"\"\"\n\n $name = Param(Params._dummy(), \"$name\", \"$doc\", typeConverter=$typ... | Generates the header part for shared variables
:param name: param name
:param doc: param doc | [
"Generates",
"the",
"header",
"part",
"for",
"shared",
"variables"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/param/_shared_params_code_gen.py#L41-L70 | train |
apache/spark | python/pyspark/ml/param/_shared_params_code_gen.py | _gen_param_code | def _gen_param_code(name, doc, defaultValueStr):
"""
Generates Python code for a shared param class.
:param name: param name
:param doc: param doc
:param defaultValueStr: string representation of the default value
:return: code string
"""
# TODO: How to correctly inherit instance attrib... | python | def _gen_param_code(name, doc, defaultValueStr):
"""
Generates Python code for a shared param class.
:param name: param name
:param doc: param doc
:param defaultValueStr: string representation of the default value
:return: code string
"""
# TODO: How to correctly inherit instance attrib... | [
"def",
"_gen_param_code",
"(",
"name",
",",
"doc",
",",
"defaultValueStr",
")",
":",
"# TODO: How to correctly inherit instance attributes?",
"template",
"=",
"'''\n def set$Name(self, value):\n \"\"\"\n Sets the value of :py:attr:`$name`.\n \"\"\"\n return s... | Generates Python code for a shared param class.
:param name: param name
:param doc: param doc
:param defaultValueStr: string representation of the default value
:return: code string | [
"Generates",
"Python",
"code",
"for",
"a",
"shared",
"param",
"class",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/param/_shared_params_code_gen.py#L73-L101 | train |
apache/spark | python/pyspark/mllib/clustering.py | BisectingKMeans.train | def train(self, rdd, k=4, maxIterations=20, minDivisibleClusterSize=1.0, seed=-1888008604):
"""
Runs the bisecting k-means algorithm return the model.
:param rdd:
Training points as an `RDD` of `Vector` or convertible
sequence types.
:param k:
The desired n... | python | def train(self, rdd, k=4, maxIterations=20, minDivisibleClusterSize=1.0, seed=-1888008604):
"""
Runs the bisecting k-means algorithm return the model.
:param rdd:
Training points as an `RDD` of `Vector` or convertible
sequence types.
:param k:
The desired n... | [
"def",
"train",
"(",
"self",
",",
"rdd",
",",
"k",
"=",
"4",
",",
"maxIterations",
"=",
"20",
",",
"minDivisibleClusterSize",
"=",
"1.0",
",",
"seed",
"=",
"-",
"1888008604",
")",
":",
"java_model",
"=",
"callMLlibFunc",
"(",
"\"trainBisectingKMeans\"",
",... | Runs the bisecting k-means algorithm return the model.
:param rdd:
Training points as an `RDD` of `Vector` or convertible
sequence types.
:param k:
The desired number of leaf clusters. The actual number could
be smaller if there are no divisible leaf clusters.
... | [
"Runs",
"the",
"bisecting",
"k",
"-",
"means",
"algorithm",
"return",
"the",
"model",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L142-L167 | train |
apache/spark | python/pyspark/mllib/clustering.py | KMeans.train | def train(cls, rdd, k, maxIterations=100, runs=1, initializationMode="k-means||",
seed=None, initializationSteps=2, epsilon=1e-4, initialModel=None):
"""
Train a k-means clustering model.
:param rdd:
Training points as an `RDD` of `Vector` or convertible
sequen... | python | def train(cls, rdd, k, maxIterations=100, runs=1, initializationMode="k-means||",
seed=None, initializationSteps=2, epsilon=1e-4, initialModel=None):
"""
Train a k-means clustering model.
:param rdd:
Training points as an `RDD` of `Vector` or convertible
sequen... | [
"def",
"train",
"(",
"cls",
",",
"rdd",
",",
"k",
",",
"maxIterations",
"=",
"100",
",",
"runs",
"=",
"1",
",",
"initializationMode",
"=",
"\"k-means||\"",
",",
"seed",
"=",
"None",
",",
"initializationSteps",
"=",
"2",
",",
"epsilon",
"=",
"1e-4",
","... | Train a k-means clustering model.
:param rdd:
Training points as an `RDD` of `Vector` or convertible
sequence types.
:param k:
Number of clusters to create.
:param maxIterations:
Maximum number of iterations allowed.
(default: 100)
:para... | [
"Train",
"a",
"k",
"-",
"means",
"clustering",
"model",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L307-L357 | train |
apache/spark | python/pyspark/mllib/clustering.py | GaussianMixture.train | def train(cls, rdd, k, convergenceTol=1e-3, maxIterations=100, seed=None, initialModel=None):
"""
Train a Gaussian Mixture clustering model.
:param rdd:
Training points as an `RDD` of `Vector` or convertible
sequence types.
:param k:
Number of independent G... | python | def train(cls, rdd, k, convergenceTol=1e-3, maxIterations=100, seed=None, initialModel=None):
"""
Train a Gaussian Mixture clustering model.
:param rdd:
Training points as an `RDD` of `Vector` or convertible
sequence types.
:param k:
Number of independent G... | [
"def",
"train",
"(",
"cls",
",",
"rdd",
",",
"k",
",",
"convergenceTol",
"=",
"1e-3",
",",
"maxIterations",
"=",
"100",
",",
"seed",
"=",
"None",
",",
"initialModel",
"=",
"None",
")",
":",
"initialModelWeights",
"=",
"None",
"initialModelMu",
"=",
"None... | Train a Gaussian Mixture clustering model.
:param rdd:
Training points as an `RDD` of `Vector` or convertible
sequence types.
:param k:
Number of independent Gaussians in the mixture model.
:param convergenceTol:
Maximum change in log-likelihood at which ... | [
"Train",
"a",
"Gaussian",
"Mixture",
"clustering",
"model",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L515-L553 | train |
apache/spark | python/pyspark/mllib/clustering.py | PowerIterationClusteringModel.load | def load(cls, sc, path):
"""
Load a model from the given path.
"""
model = cls._load_java(sc, path)
wrapper =\
sc._jvm.org.apache.spark.mllib.api.python.PowerIterationClusteringModelWrapper(model)
return PowerIterationClusteringModel(wrapper) | python | def load(cls, sc, path):
"""
Load a model from the given path.
"""
model = cls._load_java(sc, path)
wrapper =\
sc._jvm.org.apache.spark.mllib.api.python.PowerIterationClusteringModelWrapper(model)
return PowerIterationClusteringModel(wrapper) | [
"def",
"load",
"(",
"cls",
",",
"sc",
",",
"path",
")",
":",
"model",
"=",
"cls",
".",
"_load_java",
"(",
"sc",
",",
"path",
")",
"wrapper",
"=",
"sc",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",
"mllib",
".",
"api",
".",
"python... | Load a model from the given path. | [
"Load",
"a",
"model",
"from",
"the",
"given",
"path",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L625-L632 | train |
apache/spark | python/pyspark/mllib/clustering.py | PowerIterationClustering.train | def train(cls, rdd, k, maxIterations=100, initMode="random"):
r"""
:param rdd:
An RDD of (i, j, s\ :sub:`ij`\) tuples representing the
affinity matrix, which is the matrix A in the PIC paper. The
similarity s\ :sub:`ij`\ must be nonnegative. This is a symmetric
... | python | def train(cls, rdd, k, maxIterations=100, initMode="random"):
r"""
:param rdd:
An RDD of (i, j, s\ :sub:`ij`\) tuples representing the
affinity matrix, which is the matrix A in the PIC paper. The
similarity s\ :sub:`ij`\ must be nonnegative. This is a symmetric
... | [
"def",
"train",
"(",
"cls",
",",
"rdd",
",",
"k",
",",
"maxIterations",
"=",
"100",
",",
"initMode",
"=",
"\"random\"",
")",
":",
"model",
"=",
"callMLlibFunc",
"(",
"\"trainPowerIterationClusteringModel\"",
",",
"rdd",
".",
"map",
"(",
"_convert_to_vector",
... | r"""
:param rdd:
An RDD of (i, j, s\ :sub:`ij`\) tuples representing the
affinity matrix, which is the matrix A in the PIC paper. The
similarity s\ :sub:`ij`\ must be nonnegative. This is a symmetric
matrix and hence s\ :sub:`ij`\ = s\ :sub:`ji`\ For any (i, j) with
... | [
"r",
":",
"param",
"rdd",
":",
"An",
"RDD",
"of",
"(",
"i",
"j",
"s",
"\\",
":",
"sub",
":",
"ij",
"\\",
")",
"tuples",
"representing",
"the",
"affinity",
"matrix",
"which",
"is",
"the",
"matrix",
"A",
"in",
"the",
"PIC",
"paper",
".",
"The",
"si... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L648-L671 | train |
apache/spark | python/pyspark/mllib/clustering.py | StreamingKMeansModel.update | def update(self, data, decayFactor, timeUnit):
"""Update the centroids, according to data
:param data:
RDD with new data for the model update.
:param decayFactor:
Forgetfulness of the previous centroids.
:param timeUnit:
Can be "batches" or "points". If poi... | python | def update(self, data, decayFactor, timeUnit):
"""Update the centroids, according to data
:param data:
RDD with new data for the model update.
:param decayFactor:
Forgetfulness of the previous centroids.
:param timeUnit:
Can be "batches" or "points". If poi... | [
"def",
"update",
"(",
"self",
",",
"data",
",",
"decayFactor",
",",
"timeUnit",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"RDD",
")",
":",
"raise",
"TypeError",
"(",
"\"Data should be of an RDD, got %s.\"",
"%",
"type",
"(",
"data",
")",
")",
... | Update the centroids, according to data
:param data:
RDD with new data for the model update.
:param decayFactor:
Forgetfulness of the previous centroids.
:param timeUnit:
Can be "batches" or "points". If points, then the decay factor
is raised to the powe... | [
"Update",
"the",
"centroids",
"according",
"to",
"data"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L752-L777 | train |
apache/spark | python/pyspark/mllib/clustering.py | StreamingKMeans.setHalfLife | def setHalfLife(self, halfLife, timeUnit):
"""
Set number of batches after which the centroids of that
particular batch has half the weightage.
"""
self._timeUnit = timeUnit
self._decayFactor = exp(log(0.5) / halfLife)
return self | python | def setHalfLife(self, halfLife, timeUnit):
"""
Set number of batches after which the centroids of that
particular batch has half the weightage.
"""
self._timeUnit = timeUnit
self._decayFactor = exp(log(0.5) / halfLife)
return self | [
"def",
"setHalfLife",
"(",
"self",
",",
"halfLife",
",",
"timeUnit",
")",
":",
"self",
".",
"_timeUnit",
"=",
"timeUnit",
"self",
".",
"_decayFactor",
"=",
"exp",
"(",
"log",
"(",
"0.5",
")",
"/",
"halfLife",
")",
"return",
"self"
] | Set number of batches after which the centroids of that
particular batch has half the weightage. | [
"Set",
"number",
"of",
"batches",
"after",
"which",
"the",
"centroids",
"of",
"that",
"particular",
"batch",
"has",
"half",
"the",
"weightage",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L838-L845 | train |
apache/spark | python/pyspark/mllib/clustering.py | StreamingKMeans.setInitialCenters | def setInitialCenters(self, centers, weights):
"""
Set initial centers. Should be set before calling trainOn.
"""
self._model = StreamingKMeansModel(centers, weights)
return self | python | def setInitialCenters(self, centers, weights):
"""
Set initial centers. Should be set before calling trainOn.
"""
self._model = StreamingKMeansModel(centers, weights)
return self | [
"def",
"setInitialCenters",
"(",
"self",
",",
"centers",
",",
"weights",
")",
":",
"self",
".",
"_model",
"=",
"StreamingKMeansModel",
"(",
"centers",
",",
"weights",
")",
"return",
"self"
] | Set initial centers. Should be set before calling trainOn. | [
"Set",
"initial",
"centers",
".",
"Should",
"be",
"set",
"before",
"calling",
"trainOn",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L848-L853 | train |
apache/spark | python/pyspark/mllib/clustering.py | StreamingKMeans.setRandomCenters | def setRandomCenters(self, dim, weight, seed):
"""
Set the initial centres to be random samples from
a gaussian population with constant weights.
"""
rng = random.RandomState(seed)
clusterCenters = rng.randn(self._k, dim)
clusterWeights = tile(weight, self._k)
... | python | def setRandomCenters(self, dim, weight, seed):
"""
Set the initial centres to be random samples from
a gaussian population with constant weights.
"""
rng = random.RandomState(seed)
clusterCenters = rng.randn(self._k, dim)
clusterWeights = tile(weight, self._k)
... | [
"def",
"setRandomCenters",
"(",
"self",
",",
"dim",
",",
"weight",
",",
"seed",
")",
":",
"rng",
"=",
"random",
".",
"RandomState",
"(",
"seed",
")",
"clusterCenters",
"=",
"rng",
".",
"randn",
"(",
"self",
".",
"_k",
",",
"dim",
")",
"clusterWeights",... | Set the initial centres to be random samples from
a gaussian population with constant weights. | [
"Set",
"the",
"initial",
"centres",
"to",
"be",
"random",
"samples",
"from",
"a",
"gaussian",
"population",
"with",
"constant",
"weights",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L856-L865 | train |
apache/spark | python/pyspark/mllib/clustering.py | StreamingKMeans.trainOn | def trainOn(self, dstream):
"""Train the model on the incoming dstream."""
self._validate(dstream)
def update(rdd):
self._model.update(rdd, self._decayFactor, self._timeUnit)
dstream.foreachRDD(update) | python | def trainOn(self, dstream):
"""Train the model on the incoming dstream."""
self._validate(dstream)
def update(rdd):
self._model.update(rdd, self._decayFactor, self._timeUnit)
dstream.foreachRDD(update) | [
"def",
"trainOn",
"(",
"self",
",",
"dstream",
")",
":",
"self",
".",
"_validate",
"(",
"dstream",
")",
"def",
"update",
"(",
"rdd",
")",
":",
"self",
".",
"_model",
".",
"update",
"(",
"rdd",
",",
"self",
".",
"_decayFactor",
",",
"self",
".",
"_t... | Train the model on the incoming dstream. | [
"Train",
"the",
"model",
"on",
"the",
"incoming",
"dstream",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L868-L875 | train |
apache/spark | python/pyspark/mllib/clustering.py | StreamingKMeans.predictOn | def predictOn(self, dstream):
"""
Make predictions on a dstream.
Returns a transformed dstream object
"""
self._validate(dstream)
return dstream.map(lambda x: self._model.predict(x)) | python | def predictOn(self, dstream):
"""
Make predictions on a dstream.
Returns a transformed dstream object
"""
self._validate(dstream)
return dstream.map(lambda x: self._model.predict(x)) | [
"def",
"predictOn",
"(",
"self",
",",
"dstream",
")",
":",
"self",
".",
"_validate",
"(",
"dstream",
")",
"return",
"dstream",
".",
"map",
"(",
"lambda",
"x",
":",
"self",
".",
"_model",
".",
"predict",
"(",
"x",
")",
")"
] | Make predictions on a dstream.
Returns a transformed dstream object | [
"Make",
"predictions",
"on",
"a",
"dstream",
".",
"Returns",
"a",
"transformed",
"dstream",
"object"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L878-L884 | train |
apache/spark | python/pyspark/mllib/clustering.py | StreamingKMeans.predictOnValues | def predictOnValues(self, dstream):
"""
Make predictions on a keyed dstream.
Returns a transformed dstream object.
"""
self._validate(dstream)
return dstream.mapValues(lambda x: self._model.predict(x)) | python | def predictOnValues(self, dstream):
"""
Make predictions on a keyed dstream.
Returns a transformed dstream object.
"""
self._validate(dstream)
return dstream.mapValues(lambda x: self._model.predict(x)) | [
"def",
"predictOnValues",
"(",
"self",
",",
"dstream",
")",
":",
"self",
".",
"_validate",
"(",
"dstream",
")",
"return",
"dstream",
".",
"mapValues",
"(",
"lambda",
"x",
":",
"self",
".",
"_model",
".",
"predict",
"(",
"x",
")",
")"
] | Make predictions on a keyed dstream.
Returns a transformed dstream object. | [
"Make",
"predictions",
"on",
"a",
"keyed",
"dstream",
".",
"Returns",
"a",
"transformed",
"dstream",
"object",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L887-L893 | train |
apache/spark | python/pyspark/mllib/clustering.py | LDAModel.describeTopics | def describeTopics(self, maxTermsPerTopic=None):
"""Return the topics described by weighted terms.
WARNING: If vocabSize and k are large, this can return a large object!
:param maxTermsPerTopic:
Maximum number of terms to collect for each topic.
(default: vocabulary size)
... | python | def describeTopics(self, maxTermsPerTopic=None):
"""Return the topics described by weighted terms.
WARNING: If vocabSize and k are large, this can return a large object!
:param maxTermsPerTopic:
Maximum number of terms to collect for each topic.
(default: vocabulary size)
... | [
"def",
"describeTopics",
"(",
"self",
",",
"maxTermsPerTopic",
"=",
"None",
")",
":",
"if",
"maxTermsPerTopic",
"is",
"None",
":",
"topics",
"=",
"self",
".",
"call",
"(",
"\"describeTopics\"",
")",
"else",
":",
"topics",
"=",
"self",
".",
"call",
"(",
"... | Return the topics described by weighted terms.
WARNING: If vocabSize and k are large, this can return a large object!
:param maxTermsPerTopic:
Maximum number of terms to collect for each topic.
(default: vocabulary size)
:return:
Array over topics. Each topic is r... | [
"Return",
"the",
"topics",
"described",
"by",
"weighted",
"terms",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L955-L972 | train |
apache/spark | python/pyspark/mllib/clustering.py | LDAModel.load | def load(cls, sc, path):
"""Load the LDAModel from disk.
:param sc:
SparkContext.
:param path:
Path to where the model is stored.
"""
if not isinstance(sc, SparkContext):
raise TypeError("sc should be a SparkContext, got type %s" % type(sc))
... | python | def load(cls, sc, path):
"""Load the LDAModel from disk.
:param sc:
SparkContext.
:param path:
Path to where the model is stored.
"""
if not isinstance(sc, SparkContext):
raise TypeError("sc should be a SparkContext, got type %s" % type(sc))
... | [
"def",
"load",
"(",
"cls",
",",
"sc",
",",
"path",
")",
":",
"if",
"not",
"isinstance",
"(",
"sc",
",",
"SparkContext",
")",
":",
"raise",
"TypeError",
"(",
"\"sc should be a SparkContext, got type %s\"",
"%",
"type",
"(",
"sc",
")",
")",
"if",
"not",
"i... | Load the LDAModel from disk.
:param sc:
SparkContext.
:param path:
Path to where the model is stored. | [
"Load",
"the",
"LDAModel",
"from",
"disk",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L976-L989 | train |
apache/spark | python/pyspark/mllib/clustering.py | LDA.train | def train(cls, rdd, k=10, maxIterations=20, docConcentration=-1.0,
topicConcentration=-1.0, seed=None, checkpointInterval=10, optimizer="em"):
"""Train a LDA model.
:param rdd:
RDD of documents, which are tuples of document IDs and term
(word) count vectors. The term c... | python | def train(cls, rdd, k=10, maxIterations=20, docConcentration=-1.0,
topicConcentration=-1.0, seed=None, checkpointInterval=10, optimizer="em"):
"""Train a LDA model.
:param rdd:
RDD of documents, which are tuples of document IDs and term
(word) count vectors. The term c... | [
"def",
"train",
"(",
"cls",
",",
"rdd",
",",
"k",
"=",
"10",
",",
"maxIterations",
"=",
"20",
",",
"docConcentration",
"=",
"-",
"1.0",
",",
"topicConcentration",
"=",
"-",
"1.0",
",",
"seed",
"=",
"None",
",",
"checkpointInterval",
"=",
"10",
",",
"... | Train a LDA model.
:param rdd:
RDD of documents, which are tuples of document IDs and term
(word) count vectors. The term count vectors are "bags of
words" with a fixed-size vocabulary (where the vocabulary size
is the length of the vector). Document IDs must be unique
... | [
"Train",
"a",
"LDA",
"model",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L999-L1039 | train |
apache/spark | python/pyspark/mllib/common.py | _to_java_object_rdd | def _to_java_object_rdd(rdd):
""" Return a JavaRDD of Object by unpickling
It will convert each Python object into Java object by Pyrolite, whenever the
RDD is serialized in batch or not.
"""
rdd = rdd._reserialize(AutoBatchedSerializer(PickleSerializer()))
return rdd.ctx._jvm.org.apache.spark.... | python | def _to_java_object_rdd(rdd):
""" Return a JavaRDD of Object by unpickling
It will convert each Python object into Java object by Pyrolite, whenever the
RDD is serialized in batch or not.
"""
rdd = rdd._reserialize(AutoBatchedSerializer(PickleSerializer()))
return rdd.ctx._jvm.org.apache.spark.... | [
"def",
"_to_java_object_rdd",
"(",
"rdd",
")",
":",
"rdd",
"=",
"rdd",
".",
"_reserialize",
"(",
"AutoBatchedSerializer",
"(",
"PickleSerializer",
"(",
")",
")",
")",
"return",
"rdd",
".",
"ctx",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",... | Return a JavaRDD of Object by unpickling
It will convert each Python object into Java object by Pyrolite, whenever the
RDD is serialized in batch or not. | [
"Return",
"a",
"JavaRDD",
"of",
"Object",
"by",
"unpickling"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/common.py#L62-L69 | train |
apache/spark | python/pyspark/mllib/common.py | _py2java | def _py2java(sc, obj):
""" Convert Python object into Java """
if isinstance(obj, RDD):
obj = _to_java_object_rdd(obj)
elif isinstance(obj, DataFrame):
obj = obj._jdf
elif isinstance(obj, SparkContext):
obj = obj._jsc
elif isinstance(obj, list):
obj = [_py2java(sc, x)... | python | def _py2java(sc, obj):
""" Convert Python object into Java """
if isinstance(obj, RDD):
obj = _to_java_object_rdd(obj)
elif isinstance(obj, DataFrame):
obj = obj._jdf
elif isinstance(obj, SparkContext):
obj = obj._jsc
elif isinstance(obj, list):
obj = [_py2java(sc, x)... | [
"def",
"_py2java",
"(",
"sc",
",",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"RDD",
")",
":",
"obj",
"=",
"_to_java_object_rdd",
"(",
"obj",
")",
"elif",
"isinstance",
"(",
"obj",
",",
"DataFrame",
")",
":",
"obj",
"=",
"obj",
".",
"_jd... | Convert Python object into Java | [
"Convert",
"Python",
"object",
"into",
"Java"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/common.py#L72-L89 | train |
apache/spark | python/pyspark/mllib/common.py | callJavaFunc | def callJavaFunc(sc, func, *args):
""" Call Java Function """
args = [_py2java(sc, a) for a in args]
return _java2py(sc, func(*args)) | python | def callJavaFunc(sc, func, *args):
""" Call Java Function """
args = [_py2java(sc, a) for a in args]
return _java2py(sc, func(*args)) | [
"def",
"callJavaFunc",
"(",
"sc",
",",
"func",
",",
"*",
"args",
")",
":",
"args",
"=",
"[",
"_py2java",
"(",
"sc",
",",
"a",
")",
"for",
"a",
"in",
"args",
"]",
"return",
"_java2py",
"(",
"sc",
",",
"func",
"(",
"*",
"args",
")",
")"
] | Call Java Function | [
"Call",
"Java",
"Function"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/common.py#L120-L123 | train |
apache/spark | python/pyspark/mllib/common.py | callMLlibFunc | def callMLlibFunc(name, *args):
""" Call API in PythonMLLibAPI """
sc = SparkContext.getOrCreate()
api = getattr(sc._jvm.PythonMLLibAPI(), name)
return callJavaFunc(sc, api, *args) | python | def callMLlibFunc(name, *args):
""" Call API in PythonMLLibAPI """
sc = SparkContext.getOrCreate()
api = getattr(sc._jvm.PythonMLLibAPI(), name)
return callJavaFunc(sc, api, *args) | [
"def",
"callMLlibFunc",
"(",
"name",
",",
"*",
"args",
")",
":",
"sc",
"=",
"SparkContext",
".",
"getOrCreate",
"(",
")",
"api",
"=",
"getattr",
"(",
"sc",
".",
"_jvm",
".",
"PythonMLLibAPI",
"(",
")",
",",
"name",
")",
"return",
"callJavaFunc",
"(",
... | Call API in PythonMLLibAPI | [
"Call",
"API",
"in",
"PythonMLLibAPI"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/common.py#L126-L130 | train |
apache/spark | python/pyspark/mllib/common.py | inherit_doc | def inherit_doc(cls):
"""
A decorator that makes a class inherit documentation from its parents.
"""
for name, func in vars(cls).items():
# only inherit docstring for public functions
if name.startswith("_"):
continue
if not func.__doc__:
for parent in cls... | python | def inherit_doc(cls):
"""
A decorator that makes a class inherit documentation from its parents.
"""
for name, func in vars(cls).items():
# only inherit docstring for public functions
if name.startswith("_"):
continue
if not func.__doc__:
for parent in cls... | [
"def",
"inherit_doc",
"(",
"cls",
")",
":",
"for",
"name",
",",
"func",
"in",
"vars",
"(",
"cls",
")",
".",
"items",
"(",
")",
":",
"# only inherit docstring for public functions",
"if",
"name",
".",
"startswith",
"(",
"\"_\"",
")",
":",
"continue",
"if",
... | A decorator that makes a class inherit documentation from its parents. | [
"A",
"decorator",
"that",
"makes",
"a",
"class",
"inherit",
"documentation",
"from",
"its",
"parents",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/common.py#L149-L163 | train |
apache/spark | python/pyspark/mllib/common.py | JavaModelWrapper.call | def call(self, name, *a):
"""Call method of java_model"""
return callJavaFunc(self._sc, getattr(self._java_model, name), *a) | python | def call(self, name, *a):
"""Call method of java_model"""
return callJavaFunc(self._sc, getattr(self._java_model, name), *a) | [
"def",
"call",
"(",
"self",
",",
"name",
",",
"*",
"a",
")",
":",
"return",
"callJavaFunc",
"(",
"self",
".",
"_sc",
",",
"getattr",
"(",
"self",
".",
"_java_model",
",",
"name",
")",
",",
"*",
"a",
")"
] | Call method of java_model | [
"Call",
"method",
"of",
"java_model"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/common.py#L144-L146 | train |
apache/spark | python/pyspark/streaming/dstream.py | DStream.count | def count(self):
"""
Return a new DStream in which each RDD has a single element
generated by counting each RDD of this DStream.
"""
return self.mapPartitions(lambda i: [sum(1 for _ in i)]).reduce(operator.add) | python | def count(self):
"""
Return a new DStream in which each RDD has a single element
generated by counting each RDD of this DStream.
"""
return self.mapPartitions(lambda i: [sum(1 for _ in i)]).reduce(operator.add) | [
"def",
"count",
"(",
"self",
")",
":",
"return",
"self",
".",
"mapPartitions",
"(",
"lambda",
"i",
":",
"[",
"sum",
"(",
"1",
"for",
"_",
"in",
"i",
")",
"]",
")",
".",
"reduce",
"(",
"operator",
".",
"add",
")"
] | Return a new DStream in which each RDD has a single element
generated by counting each RDD of this DStream. | [
"Return",
"a",
"new",
"DStream",
"in",
"which",
"each",
"RDD",
"has",
"a",
"single",
"element",
"generated",
"by",
"counting",
"each",
"RDD",
"of",
"this",
"DStream",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L73-L78 | train |
apache/spark | python/pyspark/streaming/dstream.py | DStream.filter | def filter(self, f):
"""
Return a new DStream containing only the elements that satisfy predicate.
"""
def func(iterator):
return filter(f, iterator)
return self.mapPartitions(func, True) | python | def filter(self, f):
"""
Return a new DStream containing only the elements that satisfy predicate.
"""
def func(iterator):
return filter(f, iterator)
return self.mapPartitions(func, True) | [
"def",
"filter",
"(",
"self",
",",
"f",
")",
":",
"def",
"func",
"(",
"iterator",
")",
":",
"return",
"filter",
"(",
"f",
",",
"iterator",
")",
"return",
"self",
".",
"mapPartitions",
"(",
"func",
",",
"True",
")"
] | Return a new DStream containing only the elements that satisfy predicate. | [
"Return",
"a",
"new",
"DStream",
"containing",
"only",
"the",
"elements",
"that",
"satisfy",
"predicate",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L80-L86 | train |
apache/spark | python/pyspark/streaming/dstream.py | DStream.map | def map(self, f, preservesPartitioning=False):
"""
Return a new DStream by applying a function to each element of DStream.
"""
def func(iterator):
return map(f, iterator)
return self.mapPartitions(func, preservesPartitioning) | python | def map(self, f, preservesPartitioning=False):
"""
Return a new DStream by applying a function to each element of DStream.
"""
def func(iterator):
return map(f, iterator)
return self.mapPartitions(func, preservesPartitioning) | [
"def",
"map",
"(",
"self",
",",
"f",
",",
"preservesPartitioning",
"=",
"False",
")",
":",
"def",
"func",
"(",
"iterator",
")",
":",
"return",
"map",
"(",
"f",
",",
"iterator",
")",
"return",
"self",
".",
"mapPartitions",
"(",
"func",
",",
"preservesPa... | Return a new DStream by applying a function to each element of DStream. | [
"Return",
"a",
"new",
"DStream",
"by",
"applying",
"a",
"function",
"to",
"each",
"element",
"of",
"DStream",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L97-L103 | train |
apache/spark | python/pyspark/streaming/dstream.py | DStream.mapPartitionsWithIndex | def mapPartitionsWithIndex(self, f, preservesPartitioning=False):
"""
Return a new DStream in which each RDD is generated by applying
mapPartitionsWithIndex() to each RDDs of this DStream.
"""
return self.transform(lambda rdd: rdd.mapPartitionsWithIndex(f, preservesPartitioning)) | python | def mapPartitionsWithIndex(self, f, preservesPartitioning=False):
"""
Return a new DStream in which each RDD is generated by applying
mapPartitionsWithIndex() to each RDDs of this DStream.
"""
return self.transform(lambda rdd: rdd.mapPartitionsWithIndex(f, preservesPartitioning)) | [
"def",
"mapPartitionsWithIndex",
"(",
"self",
",",
"f",
",",
"preservesPartitioning",
"=",
"False",
")",
":",
"return",
"self",
".",
"transform",
"(",
"lambda",
"rdd",
":",
"rdd",
".",
"mapPartitionsWithIndex",
"(",
"f",
",",
"preservesPartitioning",
")",
")"
... | Return a new DStream in which each RDD is generated by applying
mapPartitionsWithIndex() to each RDDs of this DStream. | [
"Return",
"a",
"new",
"DStream",
"in",
"which",
"each",
"RDD",
"is",
"generated",
"by",
"applying",
"mapPartitionsWithIndex",
"()",
"to",
"each",
"RDDs",
"of",
"this",
"DStream",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L114-L119 | train |
apache/spark | python/pyspark/streaming/dstream.py | DStream.reduce | def reduce(self, func):
"""
Return a new DStream in which each RDD has a single element
generated by reducing each RDD of this DStream.
"""
return self.map(lambda x: (None, x)).reduceByKey(func, 1).map(lambda x: x[1]) | python | def reduce(self, func):
"""
Return a new DStream in which each RDD has a single element
generated by reducing each RDD of this DStream.
"""
return self.map(lambda x: (None, x)).reduceByKey(func, 1).map(lambda x: x[1]) | [
"def",
"reduce",
"(",
"self",
",",
"func",
")",
":",
"return",
"self",
".",
"map",
"(",
"lambda",
"x",
":",
"(",
"None",
",",
"x",
")",
")",
".",
"reduceByKey",
"(",
"func",
",",
"1",
")",
".",
"map",
"(",
"lambda",
"x",
":",
"x",
"[",
"1",
... | Return a new DStream in which each RDD has a single element
generated by reducing each RDD of this DStream. | [
"Return",
"a",
"new",
"DStream",
"in",
"which",
"each",
"RDD",
"has",
"a",
"single",
"element",
"generated",
"by",
"reducing",
"each",
"RDD",
"of",
"this",
"DStream",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L121-L126 | train |
apache/spark | python/pyspark/streaming/dstream.py | DStream.reduceByKey | def reduceByKey(self, func, numPartitions=None):
"""
Return a new DStream by applying reduceByKey to each RDD.
"""
if numPartitions is None:
numPartitions = self._sc.defaultParallelism
return self.combineByKey(lambda x: x, func, func, numPartitions) | python | def reduceByKey(self, func, numPartitions=None):
"""
Return a new DStream by applying reduceByKey to each RDD.
"""
if numPartitions is None:
numPartitions = self._sc.defaultParallelism
return self.combineByKey(lambda x: x, func, func, numPartitions) | [
"def",
"reduceByKey",
"(",
"self",
",",
"func",
",",
"numPartitions",
"=",
"None",
")",
":",
"if",
"numPartitions",
"is",
"None",
":",
"numPartitions",
"=",
"self",
".",
"_sc",
".",
"defaultParallelism",
"return",
"self",
".",
"combineByKey",
"(",
"lambda",
... | Return a new DStream by applying reduceByKey to each RDD. | [
"Return",
"a",
"new",
"DStream",
"by",
"applying",
"reduceByKey",
"to",
"each",
"RDD",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L128-L134 | train |
apache/spark | python/pyspark/streaming/dstream.py | DStream.combineByKey | def combineByKey(self, createCombiner, mergeValue, mergeCombiners,
numPartitions=None):
"""
Return a new DStream by applying combineByKey to each RDD.
"""
if numPartitions is None:
numPartitions = self._sc.defaultParallelism
def func(rdd):
... | python | def combineByKey(self, createCombiner, mergeValue, mergeCombiners,
numPartitions=None):
"""
Return a new DStream by applying combineByKey to each RDD.
"""
if numPartitions is None:
numPartitions = self._sc.defaultParallelism
def func(rdd):
... | [
"def",
"combineByKey",
"(",
"self",
",",
"createCombiner",
",",
"mergeValue",
",",
"mergeCombiners",
",",
"numPartitions",
"=",
"None",
")",
":",
"if",
"numPartitions",
"is",
"None",
":",
"numPartitions",
"=",
"self",
".",
"_sc",
".",
"defaultParallelism",
"de... | Return a new DStream by applying combineByKey to each RDD. | [
"Return",
"a",
"new",
"DStream",
"by",
"applying",
"combineByKey",
"to",
"each",
"RDD",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L136-L146 | train |
apache/spark | python/pyspark/streaming/dstream.py | DStream.partitionBy | def partitionBy(self, numPartitions, partitionFunc=portable_hash):
"""
Return a copy of the DStream in which each RDD are partitioned
using the specified partitioner.
"""
return self.transform(lambda rdd: rdd.partitionBy(numPartitions, partitionFunc)) | python | def partitionBy(self, numPartitions, partitionFunc=portable_hash):
"""
Return a copy of the DStream in which each RDD are partitioned
using the specified partitioner.
"""
return self.transform(lambda rdd: rdd.partitionBy(numPartitions, partitionFunc)) | [
"def",
"partitionBy",
"(",
"self",
",",
"numPartitions",
",",
"partitionFunc",
"=",
"portable_hash",
")",
":",
"return",
"self",
".",
"transform",
"(",
"lambda",
"rdd",
":",
"rdd",
".",
"partitionBy",
"(",
"numPartitions",
",",
"partitionFunc",
")",
")"
] | Return a copy of the DStream in which each RDD are partitioned
using the specified partitioner. | [
"Return",
"a",
"copy",
"of",
"the",
"DStream",
"in",
"which",
"each",
"RDD",
"are",
"partitioned",
"using",
"the",
"specified",
"partitioner",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L148-L153 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.