partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | parsePoint | Parse a line of text into an MLlib LabeledPoint object. | examples/src/main/python/mllib/logistic_regression.py | def parsePoint(line):
"""
Parse a line of text into an MLlib LabeledPoint object.
"""
values = [float(s) for s in line.split(' ')]
if values[0] == -1: # Convert -1 labels to 0 for MLlib
values[0] = 0
return LabeledPoint(values[0], values[1:]) | def parsePoint(line):
"""
Parse a line of text into an MLlib LabeledPoint object.
"""
values = [float(s) for s in line.split(' ')]
if values[0] == -1: # Convert -1 labels to 0 for MLlib
values[0] = 0
return LabeledPoint(values[0], values[1:]) | [
"Parse",
"a",
"line",
"of",
"text",
"into",
"an",
"MLlib",
"LabeledPoint",
"object",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/examples/src/main/python/mllib/logistic_regression.py#L32-L39 | [
"def",
"parsePoint",
"(",
"line",
")",
":",
"values",
"=",
"[",
"float",
"(",
"s",
")",
"for",
"s",
"in",
"line",
".",
"split",
"(",
"' '",
")",
"]",
"if",
"values",
"[",
"0",
"]",
"==",
"-",
"1",
":",
"# Convert -1 labels to 0 for MLlib",
"values",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | MulticlassMetrics.fMeasure | Returns f-measure. | python/pyspark/mllib/evaluation.py | def fMeasure(self, label, beta=None):
"""
Returns f-measure.
"""
if beta is None:
return self.call("fMeasure", label)
else:
return self.call("fMeasure", label, beta) | def fMeasure(self, label, beta=None):
"""
Returns f-measure.
"""
if beta is None:
return self.call("fMeasure", label)
else:
return self.call("fMeasure", label, beta) | [
"Returns",
"f",
"-",
"measure",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/evaluation.py#L297-L304 | [
"def",
"fMeasure",
"(",
"self",
",",
"label",
",",
"beta",
"=",
"None",
")",
":",
"if",
"beta",
"is",
"None",
":",
"return",
"self",
".",
"call",
"(",
"\"fMeasure\"",
",",
"label",
")",
"else",
":",
"return",
"self",
".",
"call",
"(",
"\"fMeasure\"",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | MultilabelMetrics.precision | Returns precision or precision for a given label (category) if specified. | python/pyspark/mllib/evaluation.py | def precision(self, label=None):
"""
Returns precision or precision for a given label (category) if specified.
"""
if label is None:
return self.call("precision")
else:
return self.call("precision", float(label)) | def precision(self, label=None):
"""
Returns precision or precision for a given label (category) if specified.
"""
if label is None:
return self.call("precision")
else:
return self.call("precision", float(label)) | [
"Returns",
"precision",
"or",
"precision",
"for",
"a",
"given",
"label",
"(",
"category",
")",
"if",
"specified",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/evaluation.py#L504-L511 | [
"def",
"precision",
"(",
"self",
",",
"label",
"=",
"None",
")",
":",
"if",
"label",
"is",
"None",
":",
"return",
"self",
".",
"call",
"(",
"\"precision\"",
")",
"else",
":",
"return",
"self",
".",
"call",
"(",
"\"precision\"",
",",
"float",
"(",
"la... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | MultilabelMetrics.recall | Returns recall or recall for a given label (category) if specified. | python/pyspark/mllib/evaluation.py | def recall(self, label=None):
"""
Returns recall or recall for a given label (category) if specified.
"""
if label is None:
return self.call("recall")
else:
return self.call("recall", float(label)) | def recall(self, label=None):
"""
Returns recall or recall for a given label (category) if specified.
"""
if label is None:
return self.call("recall")
else:
return self.call("recall", float(label)) | [
"Returns",
"recall",
"or",
"recall",
"for",
"a",
"given",
"label",
"(",
"category",
")",
"if",
"specified",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/evaluation.py#L514-L521 | [
"def",
"recall",
"(",
"self",
",",
"label",
"=",
"None",
")",
":",
"if",
"label",
"is",
"None",
":",
"return",
"self",
".",
"call",
"(",
"\"recall\"",
")",
"else",
":",
"return",
"self",
".",
"call",
"(",
"\"recall\"",
",",
"float",
"(",
"label",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | MultilabelMetrics.f1Measure | Returns f1Measure or f1Measure for a given label (category) if specified. | python/pyspark/mllib/evaluation.py | def f1Measure(self, label=None):
"""
Returns f1Measure or f1Measure for a given label (category) if specified.
"""
if label is None:
return self.call("f1Measure")
else:
return self.call("f1Measure", float(label)) | def f1Measure(self, label=None):
"""
Returns f1Measure or f1Measure for a given label (category) if specified.
"""
if label is None:
return self.call("f1Measure")
else:
return self.call("f1Measure", float(label)) | [
"Returns",
"f1Measure",
"or",
"f1Measure",
"for",
"a",
"given",
"label",
"(",
"category",
")",
"if",
"specified",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/evaluation.py#L524-L531 | [
"def",
"f1Measure",
"(",
"self",
",",
"label",
"=",
"None",
")",
":",
"if",
"label",
"is",
"None",
":",
"return",
"self",
".",
"call",
"(",
"\"f1Measure\"",
")",
"else",
":",
"return",
"self",
".",
"call",
"(",
"\"f1Measure\"",
",",
"float",
"(",
"la... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _to_corrected_pandas_type | When converting Spark SQL records to Pandas DataFrame, the inferred data type may be wrong.
This method gets the corrected data type for Pandas if that type may be inferred uncorrectly. | python/pyspark/sql/dataframe.py | def _to_corrected_pandas_type(dt):
"""
When converting Spark SQL records to Pandas DataFrame, the inferred data type may be wrong.
This method gets the corrected data type for Pandas if that type may be inferred uncorrectly.
"""
import numpy as np
if type(dt) == ByteType:
return np.int8
... | def _to_corrected_pandas_type(dt):
"""
When converting Spark SQL records to Pandas DataFrame, the inferred data type may be wrong.
This method gets the corrected data type for Pandas if that type may be inferred uncorrectly.
"""
import numpy as np
if type(dt) == ByteType:
return np.int8
... | [
"When",
"converting",
"Spark",
"SQL",
"records",
"to",
"Pandas",
"DataFrame",
"the",
"inferred",
"data",
"type",
"may",
"be",
"wrong",
".",
"This",
"method",
"gets",
"the",
"corrected",
"data",
"type",
"for",
"Pandas",
"if",
"that",
"type",
"may",
"be",
"i... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L2239-L2254 | [
"def",
"_to_corrected_pandas_type",
"(",
"dt",
")",
":",
"import",
"numpy",
"as",
"np",
"if",
"type",
"(",
"dt",
")",
"==",
"ByteType",
":",
"return",
"np",
".",
"int8",
"elif",
"type",
"(",
"dt",
")",
"==",
"ShortType",
":",
"return",
"np",
".",
"in... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.rdd | Returns the content as an :class:`pyspark.RDD` of :class:`Row`. | python/pyspark/sql/dataframe.py | def rdd(self):
"""Returns the content as an :class:`pyspark.RDD` of :class:`Row`.
"""
if self._lazy_rdd is None:
jrdd = self._jdf.javaToPython()
self._lazy_rdd = RDD(jrdd, self.sql_ctx._sc, BatchedSerializer(PickleSerializer()))
return self._lazy_rdd | def rdd(self):
"""Returns the content as an :class:`pyspark.RDD` of :class:`Row`.
"""
if self._lazy_rdd is None:
jrdd = self._jdf.javaToPython()
self._lazy_rdd = RDD(jrdd, self.sql_ctx._sc, BatchedSerializer(PickleSerializer()))
return self._lazy_rdd | [
"Returns",
"the",
"content",
"as",
"an",
":",
"class",
":",
"pyspark",
".",
"RDD",
"of",
":",
"class",
":",
"Row",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L87-L93 | [
"def",
"rdd",
"(",
"self",
")",
":",
"if",
"self",
".",
"_lazy_rdd",
"is",
"None",
":",
"jrdd",
"=",
"self",
".",
"_jdf",
".",
"javaToPython",
"(",
")",
"self",
".",
"_lazy_rdd",
"=",
"RDD",
"(",
"jrdd",
",",
"self",
".",
"sql_ctx",
".",
"_sc",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.toJSON | Converts a :class:`DataFrame` into a :class:`RDD` of string.
Each row is turned into a JSON document as one element in the returned RDD.
>>> df.toJSON().first()
u'{"age":2,"name":"Alice"}' | python/pyspark/sql/dataframe.py | def toJSON(self, use_unicode=True):
"""Converts a :class:`DataFrame` into a :class:`RDD` of string.
Each row is turned into a JSON document as one element in the returned RDD.
>>> df.toJSON().first()
u'{"age":2,"name":"Alice"}'
"""
rdd = self._jdf.toJSON()
retur... | def toJSON(self, use_unicode=True):
"""Converts a :class:`DataFrame` into a :class:`RDD` of string.
Each row is turned into a JSON document as one element in the returned RDD.
>>> df.toJSON().first()
u'{"age":2,"name":"Alice"}'
"""
rdd = self._jdf.toJSON()
retur... | [
"Converts",
"a",
":",
"class",
":",
"DataFrame",
"into",
"a",
":",
"class",
":",
"RDD",
"of",
"string",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L111-L120 | [
"def",
"toJSON",
"(",
"self",
",",
"use_unicode",
"=",
"True",
")",
":",
"rdd",
"=",
"self",
".",
"_jdf",
".",
"toJSON",
"(",
")",
"return",
"RDD",
"(",
"rdd",
".",
"toJavaRDD",
"(",
")",
",",
"self",
".",
"_sc",
",",
"UTF8Deserializer",
"(",
"use_... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.schema | Returns the schema of this :class:`DataFrame` as a :class:`pyspark.sql.types.StructType`.
>>> df.schema
StructType(List(StructField(age,IntegerType,true),StructField(name,StringType,true))) | python/pyspark/sql/dataframe.py | def schema(self):
"""Returns the schema of this :class:`DataFrame` as a :class:`pyspark.sql.types.StructType`.
>>> df.schema
StructType(List(StructField(age,IntegerType,true),StructField(name,StringType,true)))
"""
if self._schema is None:
try:
self._... | def schema(self):
"""Returns the schema of this :class:`DataFrame` as a :class:`pyspark.sql.types.StructType`.
>>> df.schema
StructType(List(StructField(age,IntegerType,true),StructField(name,StringType,true)))
"""
if self._schema is None:
try:
self._... | [
"Returns",
"the",
"schema",
"of",
"this",
":",
"class",
":",
"DataFrame",
"as",
"a",
":",
"class",
":",
"pyspark",
".",
"sql",
".",
"types",
".",
"StructType",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L226-L238 | [
"def",
"schema",
"(",
"self",
")",
":",
"if",
"self",
".",
"_schema",
"is",
"None",
":",
"try",
":",
"self",
".",
"_schema",
"=",
"_parse_datatype_json_string",
"(",
"self",
".",
"_jdf",
".",
"schema",
"(",
")",
".",
"json",
"(",
")",
")",
"except",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.explain | Prints the (logical and physical) plans to the console for debugging purpose.
:param extended: boolean, default ``False``. If ``False``, prints only the physical plan.
>>> df.explain()
== Physical Plan ==
*(1) Scan ExistingRDD[age#0,name#1]
>>> df.explain(True)
== Pars... | python/pyspark/sql/dataframe.py | def explain(self, extended=False):
"""Prints the (logical and physical) plans to the console for debugging purpose.
:param extended: boolean, default ``False``. If ``False``, prints only the physical plan.
>>> df.explain()
== Physical Plan ==
*(1) Scan ExistingRDD[age#0,name#1]... | def explain(self, extended=False):
"""Prints the (logical and physical) plans to the console for debugging purpose.
:param extended: boolean, default ``False``. If ``False``, prints only the physical plan.
>>> df.explain()
== Physical Plan ==
*(1) Scan ExistingRDD[age#0,name#1]... | [
"Prints",
"the",
"(",
"logical",
"and",
"physical",
")",
"plans",
"to",
"the",
"console",
"for",
"debugging",
"purpose",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L253-L275 | [
"def",
"explain",
"(",
"self",
",",
"extended",
"=",
"False",
")",
":",
"if",
"extended",
":",
"print",
"(",
"self",
".",
"_jdf",
".",
"queryExecution",
"(",
")",
".",
"toString",
"(",
")",
")",
"else",
":",
"print",
"(",
"self",
".",
"_jdf",
".",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.exceptAll | Return a new :class:`DataFrame` containing rows in this :class:`DataFrame` but
not in another :class:`DataFrame` while preserving duplicates.
This is equivalent to `EXCEPT ALL` in SQL.
>>> df1 = spark.createDataFrame(
... [("a", 1), ("a", 1), ("a", 1), ("a", 2), ("b", 3), ("c"... | python/pyspark/sql/dataframe.py | def exceptAll(self, other):
"""Return a new :class:`DataFrame` containing rows in this :class:`DataFrame` but
not in another :class:`DataFrame` while preserving duplicates.
This is equivalent to `EXCEPT ALL` in SQL.
>>> df1 = spark.createDataFrame(
... [("a", 1), ("a", ... | def exceptAll(self, other):
"""Return a new :class:`DataFrame` containing rows in this :class:`DataFrame` but
not in another :class:`DataFrame` while preserving duplicates.
This is equivalent to `EXCEPT ALL` in SQL.
>>> df1 = spark.createDataFrame(
... [("a", 1), ("a", ... | [
"Return",
"a",
"new",
":",
"class",
":",
"DataFrame",
"containing",
"rows",
"in",
"this",
":",
"class",
":",
"DataFrame",
"but",
"not",
"in",
"another",
":",
"class",
":",
"DataFrame",
"while",
"preserving",
"duplicates",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L278-L300 | [
"def",
"exceptAll",
"(",
"self",
",",
"other",
")",
":",
"return",
"DataFrame",
"(",
"self",
".",
"_jdf",
".",
"exceptAll",
"(",
"other",
".",
"_jdf",
")",
",",
"self",
".",
"sql_ctx",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.show | Prints the first ``n`` rows to the console.
:param n: Number of rows to show.
:param truncate: If set to True, truncate strings longer than 20 chars by default.
If set to a number greater than one, truncates long strings to length ``truncate``
and align cells right.
:par... | python/pyspark/sql/dataframe.py | def show(self, n=20, truncate=True, vertical=False):
"""Prints the first ``n`` rows to the console.
:param n: Number of rows to show.
:param truncate: If set to True, truncate strings longer than 20 chars by default.
If set to a number greater than one, truncates long strings to len... | def show(self, n=20, truncate=True, vertical=False):
"""Prints the first ``n`` rows to the console.
:param n: Number of rows to show.
:param truncate: If set to True, truncate strings longer than 20 chars by default.
If set to a number greater than one, truncates long strings to len... | [
"Prints",
"the",
"first",
"n",
"rows",
"to",
"the",
"console",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L324-L361 | [
"def",
"show",
"(",
"self",
",",
"n",
"=",
"20",
",",
"truncate",
"=",
"True",
",",
"vertical",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"truncate",
",",
"bool",
")",
"and",
"truncate",
":",
"print",
"(",
"self",
".",
"_jdf",
".",
"showStri... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame._repr_html_ | Returns a dataframe with html code when you enabled eager evaluation
by 'spark.sql.repl.eagerEval.enabled', this only called by REPL you are
using support eager evaluation with HTML. | python/pyspark/sql/dataframe.py | def _repr_html_(self):
"""Returns a dataframe with html code when you enabled eager evaluation
by 'spark.sql.repl.eagerEval.enabled', this only called by REPL you are
using support eager evaluation with HTML.
"""
import cgi
if not self._support_repr_html:
self... | def _repr_html_(self):
"""Returns a dataframe with html code when you enabled eager evaluation
by 'spark.sql.repl.eagerEval.enabled', this only called by REPL you are
using support eager evaluation with HTML.
"""
import cgi
if not self._support_repr_html:
self... | [
"Returns",
"a",
"dataframe",
"with",
"html",
"code",
"when",
"you",
"enabled",
"eager",
"evaluation",
"by",
"spark",
".",
"sql",
".",
"repl",
".",
"eagerEval",
".",
"enabled",
"this",
"only",
"called",
"by",
"REPL",
"you",
"are",
"using",
"support",
"eager... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L372-L403 | [
"def",
"_repr_html_",
"(",
"self",
")",
":",
"import",
"cgi",
"if",
"not",
"self",
".",
"_support_repr_html",
":",
"self",
".",
"_support_repr_html",
"=",
"True",
"if",
"self",
".",
"sql_ctx",
".",
"_conf",
".",
"isReplEagerEvalEnabled",
"(",
")",
":",
"ma... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.checkpoint | Returns a checkpointed version of this Dataset. Checkpointing can be used to truncate the
logical plan of this DataFrame, which is especially useful in iterative algorithms where the
plan may grow exponentially. It will be saved to files inside the checkpoint
directory set with L{SparkContext.se... | python/pyspark/sql/dataframe.py | def checkpoint(self, eager=True):
"""Returns a checkpointed version of this Dataset. Checkpointing can be used to truncate the
logical plan of this DataFrame, which is especially useful in iterative algorithms where the
plan may grow exponentially. It will be saved to files inside the checkpoint... | def checkpoint(self, eager=True):
"""Returns a checkpointed version of this Dataset. Checkpointing can be used to truncate the
logical plan of this DataFrame, which is especially useful in iterative algorithms where the
plan may grow exponentially. It will be saved to files inside the checkpoint... | [
"Returns",
"a",
"checkpointed",
"version",
"of",
"this",
"Dataset",
".",
"Checkpointing",
"can",
"be",
"used",
"to",
"truncate",
"the",
"logical",
"plan",
"of",
"this",
"DataFrame",
"which",
"is",
"especially",
"useful",
"in",
"iterative",
"algorithms",
"where",... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L406-L417 | [
"def",
"checkpoint",
"(",
"self",
",",
"eager",
"=",
"True",
")",
":",
"jdf",
"=",
"self",
".",
"_jdf",
".",
"checkpoint",
"(",
"eager",
")",
"return",
"DataFrame",
"(",
"jdf",
",",
"self",
".",
"sql_ctx",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.localCheckpoint | Returns a locally checkpointed version of this Dataset. Checkpointing can be used to
truncate the logical plan of this DataFrame, which is especially useful in iterative
algorithms where the plan may grow exponentially. Local checkpoints are stored in the
executors using the caching subsystem an... | python/pyspark/sql/dataframe.py | def localCheckpoint(self, eager=True):
"""Returns a locally checkpointed version of this Dataset. Checkpointing can be used to
truncate the logical plan of this DataFrame, which is especially useful in iterative
algorithms where the plan may grow exponentially. Local checkpoints are stored in th... | def localCheckpoint(self, eager=True):
"""Returns a locally checkpointed version of this Dataset. Checkpointing can be used to
truncate the logical plan of this DataFrame, which is especially useful in iterative
algorithms where the plan may grow exponentially. Local checkpoints are stored in th... | [
"Returns",
"a",
"locally",
"checkpointed",
"version",
"of",
"this",
"Dataset",
".",
"Checkpointing",
"can",
"be",
"used",
"to",
"truncate",
"the",
"logical",
"plan",
"of",
"this",
"DataFrame",
"which",
"is",
"especially",
"useful",
"in",
"iterative",
"algorithms... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L420-L431 | [
"def",
"localCheckpoint",
"(",
"self",
",",
"eager",
"=",
"True",
")",
":",
"jdf",
"=",
"self",
".",
"_jdf",
".",
"localCheckpoint",
"(",
"eager",
")",
"return",
"DataFrame",
"(",
"jdf",
",",
"self",
".",
"sql_ctx",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.withWatermark | Defines an event time watermark for this :class:`DataFrame`. A watermark tracks a point
in time before which we assume no more late data is going to arrive.
Spark will use this watermark for several purposes:
- To know when a given time window aggregation can be finalized and thus can be emit... | python/pyspark/sql/dataframe.py | def withWatermark(self, eventTime, delayThreshold):
"""Defines an event time watermark for this :class:`DataFrame`. A watermark tracks a point
in time before which we assume no more late data is going to arrive.
Spark will use this watermark for several purposes:
- To know when a give... | def withWatermark(self, eventTime, delayThreshold):
"""Defines an event time watermark for this :class:`DataFrame`. A watermark tracks a point
in time before which we assume no more late data is going to arrive.
Spark will use this watermark for several purposes:
- To know when a give... | [
"Defines",
"an",
"event",
"time",
"watermark",
"for",
"this",
":",
"class",
":",
"DataFrame",
".",
"A",
"watermark",
"tracks",
"a",
"point",
"in",
"time",
"before",
"which",
"we",
"assume",
"no",
"more",
"late",
"data",
"is",
"going",
"to",
"arrive",
"."... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L434-L465 | [
"def",
"withWatermark",
"(",
"self",
",",
"eventTime",
",",
"delayThreshold",
")",
":",
"if",
"not",
"eventTime",
"or",
"type",
"(",
"eventTime",
")",
"is",
"not",
"str",
":",
"raise",
"TypeError",
"(",
"\"eventTime should be provided as a string\"",
")",
"if",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.hint | Specifies some hint on the current DataFrame.
:param name: A name of the hint.
:param parameters: Optional parameters.
:return: :class:`DataFrame`
>>> df.join(df2.hint("broadcast"), "name").show()
+----+---+------+
|name|age|height|
+----+---+------+
| B... | python/pyspark/sql/dataframe.py | def hint(self, name, *parameters):
"""Specifies some hint on the current DataFrame.
:param name: A name of the hint.
:param parameters: Optional parameters.
:return: :class:`DataFrame`
>>> df.join(df2.hint("broadcast"), "name").show()
+----+---+------+
|name|age... | def hint(self, name, *parameters):
"""Specifies some hint on the current DataFrame.
:param name: A name of the hint.
:param parameters: Optional parameters.
:return: :class:`DataFrame`
>>> df.join(df2.hint("broadcast"), "name").show()
+----+---+------+
|name|age... | [
"Specifies",
"some",
"hint",
"on",
"the",
"current",
"DataFrame",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L468-L496 | [
"def",
"hint",
"(",
"self",
",",
"name",
",",
"*",
"parameters",
")",
":",
"if",
"len",
"(",
"parameters",
")",
"==",
"1",
"and",
"isinstance",
"(",
"parameters",
"[",
"0",
"]",
",",
"list",
")",
":",
"parameters",
"=",
"parameters",
"[",
"0",
"]",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.collect | Returns all the records as a list of :class:`Row`.
>>> df.collect()
[Row(age=2, name=u'Alice'), Row(age=5, name=u'Bob')] | python/pyspark/sql/dataframe.py | def collect(self):
"""Returns all the records as a list of :class:`Row`.
>>> df.collect()
[Row(age=2, name=u'Alice'), Row(age=5, name=u'Bob')]
"""
with SCCallSiteSync(self._sc) as css:
sock_info = self._jdf.collectToPython()
return list(_load_from_socket(sock... | def collect(self):
"""Returns all the records as a list of :class:`Row`.
>>> df.collect()
[Row(age=2, name=u'Alice'), Row(age=5, name=u'Bob')]
"""
with SCCallSiteSync(self._sc) as css:
sock_info = self._jdf.collectToPython()
return list(_load_from_socket(sock... | [
"Returns",
"all",
"the",
"records",
"as",
"a",
"list",
"of",
":",
"class",
":",
"Row",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L509-L517 | [
"def",
"collect",
"(",
"self",
")",
":",
"with",
"SCCallSiteSync",
"(",
"self",
".",
"_sc",
")",
"as",
"css",
":",
"sock_info",
"=",
"self",
".",
"_jdf",
".",
"collectToPython",
"(",
")",
"return",
"list",
"(",
"_load_from_socket",
"(",
"sock_info",
",",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.toLocalIterator | Returns an iterator that contains all of the rows in this :class:`DataFrame`.
The iterator will consume as much memory as the largest partition in this DataFrame.
>>> list(df.toLocalIterator())
[Row(age=2, name=u'Alice'), Row(age=5, name=u'Bob')] | python/pyspark/sql/dataframe.py | def toLocalIterator(self):
"""
Returns an iterator that contains all of the rows in this :class:`DataFrame`.
The iterator will consume as much memory as the largest partition in this DataFrame.
>>> list(df.toLocalIterator())
[Row(age=2, name=u'Alice'), Row(age=5, name=u'Bob')]
... | def toLocalIterator(self):
"""
Returns an iterator that contains all of the rows in this :class:`DataFrame`.
The iterator will consume as much memory as the largest partition in this DataFrame.
>>> list(df.toLocalIterator())
[Row(age=2, name=u'Alice'), Row(age=5, name=u'Bob')]
... | [
"Returns",
"an",
"iterator",
"that",
"contains",
"all",
"of",
"the",
"rows",
"in",
"this",
":",
"class",
":",
"DataFrame",
".",
"The",
"iterator",
"will",
"consume",
"as",
"much",
"memory",
"as",
"the",
"largest",
"partition",
"in",
"this",
"DataFrame",
".... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L521-L531 | [
"def",
"toLocalIterator",
"(",
"self",
")",
":",
"with",
"SCCallSiteSync",
"(",
"self",
".",
"_sc",
")",
"as",
"css",
":",
"sock_info",
"=",
"self",
".",
"_jdf",
".",
"toPythonIterator",
"(",
")",
"return",
"_load_from_socket",
"(",
"sock_info",
",",
"Batc... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.limit | Limits the result count to the number specified.
>>> df.limit(1).collect()
[Row(age=2, name=u'Alice')]
>>> df.limit(0).collect()
[] | python/pyspark/sql/dataframe.py | def limit(self, num):
"""Limits the result count to the number specified.
>>> df.limit(1).collect()
[Row(age=2, name=u'Alice')]
>>> df.limit(0).collect()
[]
"""
jdf = self._jdf.limit(num)
return DataFrame(jdf, self.sql_ctx) | def limit(self, num):
"""Limits the result count to the number specified.
>>> df.limit(1).collect()
[Row(age=2, name=u'Alice')]
>>> df.limit(0).collect()
[]
"""
jdf = self._jdf.limit(num)
return DataFrame(jdf, self.sql_ctx) | [
"Limits",
"the",
"result",
"count",
"to",
"the",
"number",
"specified",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L535-L544 | [
"def",
"limit",
"(",
"self",
",",
"num",
")",
":",
"jdf",
"=",
"self",
".",
"_jdf",
".",
"limit",
"(",
"num",
")",
"return",
"DataFrame",
"(",
"jdf",
",",
"self",
".",
"sql_ctx",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.persist | Sets the storage level to persist the contents of the :class:`DataFrame` across
operations after the first time it is computed. This can only be used to assign
a new storage level if the :class:`DataFrame` does not have a storage level set yet.
If no storage level is specified defaults to (C{MEM... | python/pyspark/sql/dataframe.py | def persist(self, storageLevel=StorageLevel.MEMORY_AND_DISK):
"""Sets the storage level to persist the contents of the :class:`DataFrame` across
operations after the first time it is computed. This can only be used to assign
a new storage level if the :class:`DataFrame` does not have a storage l... | def persist(self, storageLevel=StorageLevel.MEMORY_AND_DISK):
"""Sets the storage level to persist the contents of the :class:`DataFrame` across
operations after the first time it is computed. This can only be used to assign
a new storage level if the :class:`DataFrame` does not have a storage l... | [
"Sets",
"the",
"storage",
"level",
"to",
"persist",
"the",
"contents",
"of",
"the",
":",
"class",
":",
"DataFrame",
"across",
"operations",
"after",
"the",
"first",
"time",
"it",
"is",
"computed",
".",
"This",
"can",
"only",
"be",
"used",
"to",
"assign",
... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L592-L603 | [
"def",
"persist",
"(",
"self",
",",
"storageLevel",
"=",
"StorageLevel",
".",
"MEMORY_AND_DISK",
")",
":",
"self",
".",
"is_cached",
"=",
"True",
"javaStorageLevel",
"=",
"self",
".",
"_sc",
".",
"_getJavaStorageLevel",
"(",
"storageLevel",
")",
"self",
".",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.storageLevel | Get the :class:`DataFrame`'s current storage level.
>>> df.storageLevel
StorageLevel(False, False, False, False, 1)
>>> df.cache().storageLevel
StorageLevel(True, True, False, True, 1)
>>> df2.persist(StorageLevel.DISK_ONLY_2).storageLevel
StorageLevel(True, False, False... | python/pyspark/sql/dataframe.py | def storageLevel(self):
"""Get the :class:`DataFrame`'s current storage level.
>>> df.storageLevel
StorageLevel(False, False, False, False, 1)
>>> df.cache().storageLevel
StorageLevel(True, True, False, True, 1)
>>> df2.persist(StorageLevel.DISK_ONLY_2).storageLevel
... | def storageLevel(self):
"""Get the :class:`DataFrame`'s current storage level.
>>> df.storageLevel
StorageLevel(False, False, False, False, 1)
>>> df.cache().storageLevel
StorageLevel(True, True, False, True, 1)
>>> df2.persist(StorageLevel.DISK_ONLY_2).storageLevel
... | [
"Get",
"the",
":",
"class",
":",
"DataFrame",
"s",
"current",
"storage",
"level",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L607-L623 | [
"def",
"storageLevel",
"(",
"self",
")",
":",
"java_storage_level",
"=",
"self",
".",
"_jdf",
".",
"storageLevel",
"(",
")",
"storage_level",
"=",
"StorageLevel",
"(",
"java_storage_level",
".",
"useDisk",
"(",
")",
",",
"java_storage_level",
".",
"useMemory",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.unpersist | Marks the :class:`DataFrame` as non-persistent, and remove all blocks for it from
memory and disk.
.. note:: `blocking` default has changed to False to match Scala in 2.0. | python/pyspark/sql/dataframe.py | def unpersist(self, blocking=False):
"""Marks the :class:`DataFrame` as non-persistent, and remove all blocks for it from
memory and disk.
.. note:: `blocking` default has changed to False to match Scala in 2.0.
"""
self.is_cached = False
self._jdf.unpersist(blocking)
... | def unpersist(self, blocking=False):
"""Marks the :class:`DataFrame` as non-persistent, and remove all blocks for it from
memory and disk.
.. note:: `blocking` default has changed to False to match Scala in 2.0.
"""
self.is_cached = False
self._jdf.unpersist(blocking)
... | [
"Marks",
"the",
":",
"class",
":",
"DataFrame",
"as",
"non",
"-",
"persistent",
"and",
"remove",
"all",
"blocks",
"for",
"it",
"from",
"memory",
"and",
"disk",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L626-L634 | [
"def",
"unpersist",
"(",
"self",
",",
"blocking",
"=",
"False",
")",
":",
"self",
".",
"is_cached",
"=",
"False",
"self",
".",
"_jdf",
".",
"unpersist",
"(",
"blocking",
")",
"return",
"self"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.coalesce | Returns a new :class:`DataFrame` that has exactly `numPartitions` partitions.
:param numPartitions: int, to specify the target number of partitions
Similar to coalesce defined on an :class:`RDD`, this operation results in a
narrow dependency, e.g. if you go from 1000 partitions to 100 partitio... | python/pyspark/sql/dataframe.py | def coalesce(self, numPartitions):
"""
Returns a new :class:`DataFrame` that has exactly `numPartitions` partitions.
:param numPartitions: int, to specify the target number of partitions
Similar to coalesce defined on an :class:`RDD`, this operation results in a
narrow dependen... | def coalesce(self, numPartitions):
"""
Returns a new :class:`DataFrame` that has exactly `numPartitions` partitions.
:param numPartitions: int, to specify the target number of partitions
Similar to coalesce defined on an :class:`RDD`, this operation results in a
narrow dependen... | [
"Returns",
"a",
"new",
":",
"class",
":",
"DataFrame",
"that",
"has",
"exactly",
"numPartitions",
"partitions",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L637-L659 | [
"def",
"coalesce",
"(",
"self",
",",
"numPartitions",
")",
":",
"return",
"DataFrame",
"(",
"self",
".",
"_jdf",
".",
"coalesce",
"(",
"numPartitions",
")",
",",
"self",
".",
"sql_ctx",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.repartition | Returns a new :class:`DataFrame` partitioned by the given partitioning expressions. The
resulting DataFrame is hash partitioned.
:param numPartitions:
can be an int to specify the target number of partitions or a Column.
If it is a Column, it will be used as the first partitioni... | python/pyspark/sql/dataframe.py | def repartition(self, numPartitions, *cols):
"""
Returns a new :class:`DataFrame` partitioned by the given partitioning expressions. The
resulting DataFrame is hash partitioned.
:param numPartitions:
can be an int to specify the target number of partitions or a Column.
... | def repartition(self, numPartitions, *cols):
"""
Returns a new :class:`DataFrame` partitioned by the given partitioning expressions. The
resulting DataFrame is hash partitioned.
:param numPartitions:
can be an int to specify the target number of partitions or a Column.
... | [
"Returns",
"a",
"new",
":",
"class",
":",
"DataFrame",
"partitioned",
"by",
"the",
"given",
"partitioning",
"expressions",
".",
"The",
"resulting",
"DataFrame",
"is",
"hash",
"partitioned",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L662-L721 | [
"def",
"repartition",
"(",
"self",
",",
"numPartitions",
",",
"*",
"cols",
")",
":",
"if",
"isinstance",
"(",
"numPartitions",
",",
"int",
")",
":",
"if",
"len",
"(",
"cols",
")",
"==",
"0",
":",
"return",
"DataFrame",
"(",
"self",
".",
"_jdf",
".",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.sample | Returns a sampled subset of this :class:`DataFrame`.
:param withReplacement: Sample with replacement or not (default False).
:param fraction: Fraction of rows to generate, range [0.0, 1.0].
:param seed: Seed for sampling (default a random seed).
.. note:: This is not guaranteed to prov... | python/pyspark/sql/dataframe.py | def sample(self, withReplacement=None, fraction=None, seed=None):
"""Returns a sampled subset of this :class:`DataFrame`.
:param withReplacement: Sample with replacement or not (default False).
:param fraction: Fraction of rows to generate, range [0.0, 1.0].
:param seed: Seed for sampli... | def sample(self, withReplacement=None, fraction=None, seed=None):
"""Returns a sampled subset of this :class:`DataFrame`.
:param withReplacement: Sample with replacement or not (default False).
:param fraction: Fraction of rows to generate, range [0.0, 1.0].
:param seed: Seed for sampli... | [
"Returns",
"a",
"sampled",
"subset",
"of",
"this",
":",
"class",
":",
"DataFrame",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L784-L846 | [
"def",
"sample",
"(",
"self",
",",
"withReplacement",
"=",
"None",
",",
"fraction",
"=",
"None",
",",
"seed",
"=",
"None",
")",
":",
"# For the cases below:",
"# sample(True, 0.5 [, seed])",
"# sample(True, fraction=0.5 [, seed])",
"# sample(withReplacement=False, fra... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.sampleBy | Returns a stratified sample without replacement based on the
fraction given on each stratum.
:param col: column that defines strata
:param fractions:
sampling fraction for each stratum. If a stratum is not
specified, we treat its fraction as zero.
:param seed: ra... | python/pyspark/sql/dataframe.py | def sampleBy(self, col, fractions, seed=None):
"""
Returns a stratified sample without replacement based on the
fraction given on each stratum.
:param col: column that defines strata
:param fractions:
sampling fraction for each stratum. If a stratum is not
... | def sampleBy(self, col, fractions, seed=None):
"""
Returns a stratified sample without replacement based on the
fraction given on each stratum.
:param col: column that defines strata
:param fractions:
sampling fraction for each stratum. If a stratum is not
... | [
"Returns",
"a",
"stratified",
"sample",
"without",
"replacement",
"based",
"on",
"the",
"fraction",
"given",
"on",
"each",
"stratum",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L849-L889 | [
"def",
"sampleBy",
"(",
"self",
",",
"col",
",",
"fractions",
",",
"seed",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"col",
",",
"basestring",
")",
":",
"col",
"=",
"Column",
"(",
"col",
")",
"elif",
"not",
"isinstance",
"(",
"col",
",",
"Col... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.randomSplit | Randomly splits this :class:`DataFrame` with the provided weights.
:param weights: list of doubles as weights with which to split the DataFrame. Weights will
be normalized if they don't sum up to 1.0.
:param seed: The seed for sampling.
>>> splits = df4.randomSplit([1.0, 2.0], 24)
... | python/pyspark/sql/dataframe.py | def randomSplit(self, weights, seed=None):
"""Randomly splits this :class:`DataFrame` with the provided weights.
:param weights: list of doubles as weights with which to split the DataFrame. Weights will
be normalized if they don't sum up to 1.0.
:param seed: The seed for sampling.
... | def randomSplit(self, weights, seed=None):
"""Randomly splits this :class:`DataFrame` with the provided weights.
:param weights: list of doubles as weights with which to split the DataFrame. Weights will
be normalized if they don't sum up to 1.0.
:param seed: The seed for sampling.
... | [
"Randomly",
"splits",
"this",
":",
"class",
":",
"DataFrame",
"with",
"the",
"provided",
"weights",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L892-L911 | [
"def",
"randomSplit",
"(",
"self",
",",
"weights",
",",
"seed",
"=",
"None",
")",
":",
"for",
"w",
"in",
"weights",
":",
"if",
"w",
"<",
"0.0",
":",
"raise",
"ValueError",
"(",
"\"Weights must be positive. Found weight value: %s\"",
"%",
"w",
")",
"seed",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.dtypes | Returns all column names and their data types as a list.
>>> df.dtypes
[('age', 'int'), ('name', 'string')] | python/pyspark/sql/dataframe.py | def dtypes(self):
"""Returns all column names and their data types as a list.
>>> df.dtypes
[('age', 'int'), ('name', 'string')]
"""
return [(str(f.name), f.dataType.simpleString()) for f in self.schema.fields] | def dtypes(self):
"""Returns all column names and their data types as a list.
>>> df.dtypes
[('age', 'int'), ('name', 'string')]
"""
return [(str(f.name), f.dataType.simpleString()) for f in self.schema.fields] | [
"Returns",
"all",
"column",
"names",
"and",
"their",
"data",
"types",
"as",
"a",
"list",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L915-L921 | [
"def",
"dtypes",
"(",
"self",
")",
":",
"return",
"[",
"(",
"str",
"(",
"f",
".",
"name",
")",
",",
"f",
".",
"dataType",
".",
"simpleString",
"(",
")",
")",
"for",
"f",
"in",
"self",
".",
"schema",
".",
"fields",
"]"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.colRegex | Selects column based on the column name specified as a regex and returns it
as :class:`Column`.
:param colName: string, column name specified as a regex.
>>> df = spark.createDataFrame([("a", 1), ("b", 2), ("c", 3)], ["Col1", "Col2"])
>>> df.select(df.colRegex("`(Col1)?+.+`")).show()
... | python/pyspark/sql/dataframe.py | def colRegex(self, colName):
"""
Selects column based on the column name specified as a regex and returns it
as :class:`Column`.
:param colName: string, column name specified as a regex.
>>> df = spark.createDataFrame([("a", 1), ("b", 2), ("c", 3)], ["Col1", "Col2"])
>... | def colRegex(self, colName):
"""
Selects column based on the column name specified as a regex and returns it
as :class:`Column`.
:param colName: string, column name specified as a regex.
>>> df = spark.createDataFrame([("a", 1), ("b", 2), ("c", 3)], ["Col1", "Col2"])
>... | [
"Selects",
"column",
"based",
"on",
"the",
"column",
"name",
"specified",
"as",
"a",
"regex",
"and",
"returns",
"it",
"as",
":",
"class",
":",
"Column",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L934-L954 | [
"def",
"colRegex",
"(",
"self",
",",
"colName",
")",
":",
"if",
"not",
"isinstance",
"(",
"colName",
",",
"basestring",
")",
":",
"raise",
"ValueError",
"(",
"\"colName should be provided as string\"",
")",
"jc",
"=",
"self",
".",
"_jdf",
".",
"colRegex",
"(... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.alias | Returns a new :class:`DataFrame` with an alias set.
:param alias: string, an alias name to be set for the DataFrame.
>>> from pyspark.sql.functions import *
>>> df_as1 = df.alias("df_as1")
>>> df_as2 = df.alias("df_as2")
>>> joined_df = df_as1.join(df_as2, col("df_as1.name") ==... | python/pyspark/sql/dataframe.py | def alias(self, alias):
"""Returns a new :class:`DataFrame` with an alias set.
:param alias: string, an alias name to be set for the DataFrame.
>>> from pyspark.sql.functions import *
>>> df_as1 = df.alias("df_as1")
>>> df_as2 = df.alias("df_as2")
>>> joined_df = df_as1... | def alias(self, alias):
"""Returns a new :class:`DataFrame` with an alias set.
:param alias: string, an alias name to be set for the DataFrame.
>>> from pyspark.sql.functions import *
>>> df_as1 = df.alias("df_as1")
>>> df_as2 = df.alias("df_as2")
>>> joined_df = df_as1... | [
"Returns",
"a",
"new",
":",
"class",
":",
"DataFrame",
"with",
"an",
"alias",
"set",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L958-L971 | [
"def",
"alias",
"(",
"self",
",",
"alias",
")",
":",
"assert",
"isinstance",
"(",
"alias",
",",
"basestring",
")",
",",
"\"alias should be a string\"",
"return",
"DataFrame",
"(",
"getattr",
"(",
"self",
".",
"_jdf",
",",
"\"as\"",
")",
"(",
"alias",
")",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.crossJoin | Returns the cartesian product with another :class:`DataFrame`.
:param other: Right side of the cartesian product.
>>> df.select("age", "name").collect()
[Row(age=2, name=u'Alice'), Row(age=5, name=u'Bob')]
>>> df2.select("name", "height").collect()
[Row(name=u'Tom', height=80),... | python/pyspark/sql/dataframe.py | def crossJoin(self, other):
"""Returns the cartesian product with another :class:`DataFrame`.
:param other: Right side of the cartesian product.
>>> df.select("age", "name").collect()
[Row(age=2, name=u'Alice'), Row(age=5, name=u'Bob')]
>>> df2.select("name", "height").collect(... | def crossJoin(self, other):
"""Returns the cartesian product with another :class:`DataFrame`.
:param other: Right side of the cartesian product.
>>> df.select("age", "name").collect()
[Row(age=2, name=u'Alice'), Row(age=5, name=u'Bob')]
>>> df2.select("name", "height").collect(... | [
"Returns",
"the",
"cartesian",
"product",
"with",
"another",
":",
"class",
":",
"DataFrame",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L975-L990 | [
"def",
"crossJoin",
"(",
"self",
",",
"other",
")",
":",
"jdf",
"=",
"self",
".",
"_jdf",
".",
"crossJoin",
"(",
"other",
".",
"_jdf",
")",
"return",
"DataFrame",
"(",
"jdf",
",",
"self",
".",
"sql_ctx",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.join | Joins with another :class:`DataFrame`, using the given join expression.
:param other: Right side of the join
:param on: a string for the join column name, a list of column names,
a join expression (Column), or a list of Columns.
If `on` is a string or a list of strings indicatin... | python/pyspark/sql/dataframe.py | def join(self, other, on=None, how=None):
"""Joins with another :class:`DataFrame`, using the given join expression.
:param other: Right side of the join
:param on: a string for the join column name, a list of column names,
a join expression (Column), or a list of Columns.
... | def join(self, other, on=None, how=None):
"""Joins with another :class:`DataFrame`, using the given join expression.
:param other: Right side of the join
:param on: a string for the join column name, a list of column names,
a join expression (Column), or a list of Columns.
... | [
"Joins",
"with",
"another",
":",
"class",
":",
"DataFrame",
"using",
"the",
"given",
"join",
"expression",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L994-L1046 | [
"def",
"join",
"(",
"self",
",",
"other",
",",
"on",
"=",
"None",
",",
"how",
"=",
"None",
")",
":",
"if",
"on",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"on",
",",
"list",
")",
":",
"on",
"=",
"[",
"on",
"]",
"if",
"on",
"is",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.sortWithinPartitions | Returns a new :class:`DataFrame` with each partition sorted by the specified column(s).
:param cols: list of :class:`Column` or column names to sort by.
:param ascending: boolean or list of boolean (default True).
Sort ascending vs. descending. Specify list for multiple sort orders.
... | python/pyspark/sql/dataframe.py | def sortWithinPartitions(self, *cols, **kwargs):
"""Returns a new :class:`DataFrame` with each partition sorted by the specified column(s).
:param cols: list of :class:`Column` or column names to sort by.
:param ascending: boolean or list of boolean (default True).
Sort ascending vs... | def sortWithinPartitions(self, *cols, **kwargs):
"""Returns a new :class:`DataFrame` with each partition sorted by the specified column(s).
:param cols: list of :class:`Column` or column names to sort by.
:param ascending: boolean or list of boolean (default True).
Sort ascending vs... | [
"Returns",
"a",
"new",
":",
"class",
":",
"DataFrame",
"with",
"each",
"partition",
"sorted",
"by",
"the",
"specified",
"column",
"(",
"s",
")",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1049-L1066 | [
"def",
"sortWithinPartitions",
"(",
"self",
",",
"*",
"cols",
",",
"*",
"*",
"kwargs",
")",
":",
"jdf",
"=",
"self",
".",
"_jdf",
".",
"sortWithinPartitions",
"(",
"self",
".",
"_sort_cols",
"(",
"cols",
",",
"kwargs",
")",
")",
"return",
"DataFrame",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame._jseq | Return a JVM Seq of Columns from a list of Column or names | python/pyspark/sql/dataframe.py | def _jseq(self, cols, converter=None):
"""Return a JVM Seq of Columns from a list of Column or names"""
return _to_seq(self.sql_ctx._sc, cols, converter) | def _jseq(self, cols, converter=None):
"""Return a JVM Seq of Columns from a list of Column or names"""
return _to_seq(self.sql_ctx._sc, cols, converter) | [
"Return",
"a",
"JVM",
"Seq",
"of",
"Columns",
"from",
"a",
"list",
"of",
"Column",
"or",
"names"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1097-L1099 | [
"def",
"_jseq",
"(",
"self",
",",
"cols",
",",
"converter",
"=",
"None",
")",
":",
"return",
"_to_seq",
"(",
"self",
".",
"sql_ctx",
".",
"_sc",
",",
"cols",
",",
"converter",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame._jcols | Return a JVM Seq of Columns from a list of Column or column names
If `cols` has only one list in it, cols[0] will be used as the list. | python/pyspark/sql/dataframe.py | def _jcols(self, *cols):
"""Return a JVM Seq of Columns from a list of Column or column names
If `cols` has only one list in it, cols[0] will be used as the list.
"""
if len(cols) == 1 and isinstance(cols[0], list):
cols = cols[0]
return self._jseq(cols, _to_java_col... | def _jcols(self, *cols):
"""Return a JVM Seq of Columns from a list of Column or column names
If `cols` has only one list in it, cols[0] will be used as the list.
"""
if len(cols) == 1 and isinstance(cols[0], list):
cols = cols[0]
return self._jseq(cols, _to_java_col... | [
"Return",
"a",
"JVM",
"Seq",
"of",
"Columns",
"from",
"a",
"list",
"of",
"Column",
"or",
"column",
"names"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1105-L1112 | [
"def",
"_jcols",
"(",
"self",
",",
"*",
"cols",
")",
":",
"if",
"len",
"(",
"cols",
")",
"==",
"1",
"and",
"isinstance",
"(",
"cols",
"[",
"0",
"]",
",",
"list",
")",
":",
"cols",
"=",
"cols",
"[",
"0",
"]",
"return",
"self",
".",
"_jseq",
"(... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame._sort_cols | Return a JVM Seq of Columns that describes the sort order | python/pyspark/sql/dataframe.py | def _sort_cols(self, cols, kwargs):
""" Return a JVM Seq of Columns that describes the sort order
"""
if not cols:
raise ValueError("should sort by at least one column")
if len(cols) == 1 and isinstance(cols[0], list):
cols = cols[0]
jcols = [_to_java_colu... | def _sort_cols(self, cols, kwargs):
""" Return a JVM Seq of Columns that describes the sort order
"""
if not cols:
raise ValueError("should sort by at least one column")
if len(cols) == 1 and isinstance(cols[0], list):
cols = cols[0]
jcols = [_to_java_colu... | [
"Return",
"a",
"JVM",
"Seq",
"of",
"Columns",
"that",
"describes",
"the",
"sort",
"order"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1114-L1131 | [
"def",
"_sort_cols",
"(",
"self",
",",
"cols",
",",
"kwargs",
")",
":",
"if",
"not",
"cols",
":",
"raise",
"ValueError",
"(",
"\"should sort by at least one column\"",
")",
"if",
"len",
"(",
"cols",
")",
"==",
"1",
"and",
"isinstance",
"(",
"cols",
"[",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.describe | Computes basic statistics for numeric and string columns.
This include count, mean, stddev, min, and max. If no columns are
given, this function computes statistics for all numerical or string columns.
.. note:: This function is meant for exploratory data analysis, as we make no
gu... | python/pyspark/sql/dataframe.py | def describe(self, *cols):
"""Computes basic statistics for numeric and string columns.
This include count, mean, stddev, min, and max. If no columns are
given, this function computes statistics for all numerical or string columns.
.. note:: This function is meant for exploratory data ... | def describe(self, *cols):
"""Computes basic statistics for numeric and string columns.
This include count, mean, stddev, min, and max. If no columns are
given, this function computes statistics for all numerical or string columns.
.. note:: This function is meant for exploratory data ... | [
"Computes",
"basic",
"statistics",
"for",
"numeric",
"and",
"string",
"columns",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1134-L1169 | [
"def",
"describe",
"(",
"self",
",",
"*",
"cols",
")",
":",
"if",
"len",
"(",
"cols",
")",
"==",
"1",
"and",
"isinstance",
"(",
"cols",
"[",
"0",
"]",
",",
"list",
")",
":",
"cols",
"=",
"cols",
"[",
"0",
"]",
"jdf",
"=",
"self",
".",
"_jdf",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.summary | Computes specified statistics for numeric and string columns. Available statistics are:
- count
- mean
- stddev
- min
- max
- arbitrary approximate percentiles specified as a percentage (eg, 75%)
If no statistics are given, this function computes count, mean, std... | python/pyspark/sql/dataframe.py | def summary(self, *statistics):
"""Computes specified statistics for numeric and string columns. Available statistics are:
- count
- mean
- stddev
- min
- max
- arbitrary approximate percentiles specified as a percentage (eg, 75%)
If no statistics are giv... | def summary(self, *statistics):
"""Computes specified statistics for numeric and string columns. Available statistics are:
- count
- mean
- stddev
- min
- max
- arbitrary approximate percentiles specified as a percentage (eg, 75%)
If no statistics are giv... | [
"Computes",
"specified",
"statistics",
"for",
"numeric",
"and",
"string",
"columns",
".",
"Available",
"statistics",
"are",
":",
"-",
"count",
"-",
"mean",
"-",
"stddev",
"-",
"min",
"-",
"max",
"-",
"arbitrary",
"approximate",
"percentiles",
"specified",
"as"... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1172-L1226 | [
"def",
"summary",
"(",
"self",
",",
"*",
"statistics",
")",
":",
"if",
"len",
"(",
"statistics",
")",
"==",
"1",
"and",
"isinstance",
"(",
"statistics",
"[",
"0",
"]",
",",
"list",
")",
":",
"statistics",
"=",
"statistics",
"[",
"0",
"]",
"jdf",
"=... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.head | Returns the first ``n`` rows.
.. note:: This method should only be used if the resulting array is expected
to be small, as all the data is loaded into the driver's memory.
:param n: int, default 1. Number of rows to return.
:return: If n is greater than 1, return a list of :class:`... | python/pyspark/sql/dataframe.py | def head(self, n=None):
"""Returns the first ``n`` rows.
.. note:: This method should only be used if the resulting array is expected
to be small, as all the data is loaded into the driver's memory.
:param n: int, default 1. Number of rows to return.
:return: If n is greate... | def head(self, n=None):
"""Returns the first ``n`` rows.
.. note:: This method should only be used if the resulting array is expected
to be small, as all the data is loaded into the driver's memory.
:param n: int, default 1. Number of rows to return.
:return: If n is greate... | [
"Returns",
"the",
"first",
"n",
"rows",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1230-L1248 | [
"def",
"head",
"(",
"self",
",",
"n",
"=",
"None",
")",
":",
"if",
"n",
"is",
"None",
":",
"rs",
"=",
"self",
".",
"head",
"(",
"1",
")",
"return",
"rs",
"[",
"0",
"]",
"if",
"rs",
"else",
"None",
"return",
"self",
".",
"take",
"(",
"n",
")... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.select | Projects a set of expressions and returns a new :class:`DataFrame`.
:param cols: list of column names (string) or expressions (:class:`Column`).
If one of the column names is '*', that column is expanded to include all columns
in the current DataFrame.
>>> df.select('*').collec... | python/pyspark/sql/dataframe.py | def select(self, *cols):
"""Projects a set of expressions and returns a new :class:`DataFrame`.
:param cols: list of column names (string) or expressions (:class:`Column`).
If one of the column names is '*', that column is expanded to include all columns
in the current DataFrame... | def select(self, *cols):
"""Projects a set of expressions and returns a new :class:`DataFrame`.
:param cols: list of column names (string) or expressions (:class:`Column`).
If one of the column names is '*', that column is expanded to include all columns
in the current DataFrame... | [
"Projects",
"a",
"set",
"of",
"expressions",
"and",
"returns",
"a",
"new",
":",
"class",
":",
"DataFrame",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1302-L1317 | [
"def",
"select",
"(",
"self",
",",
"*",
"cols",
")",
":",
"jdf",
"=",
"self",
".",
"_jdf",
".",
"select",
"(",
"self",
".",
"_jcols",
"(",
"*",
"cols",
")",
")",
"return",
"DataFrame",
"(",
"jdf",
",",
"self",
".",
"sql_ctx",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.selectExpr | Projects a set of SQL expressions and returns a new :class:`DataFrame`.
This is a variant of :func:`select` that accepts SQL expressions.
>>> df.selectExpr("age * 2", "abs(age)").collect()
[Row((age * 2)=4, abs(age)=2), Row((age * 2)=10, abs(age)=5)] | python/pyspark/sql/dataframe.py | def selectExpr(self, *expr):
"""Projects a set of SQL expressions and returns a new :class:`DataFrame`.
This is a variant of :func:`select` that accepts SQL expressions.
>>> df.selectExpr("age * 2", "abs(age)").collect()
[Row((age * 2)=4, abs(age)=2), Row((age * 2)=10, abs(age)=5)]
... | def selectExpr(self, *expr):
"""Projects a set of SQL expressions and returns a new :class:`DataFrame`.
This is a variant of :func:`select` that accepts SQL expressions.
>>> df.selectExpr("age * 2", "abs(age)").collect()
[Row((age * 2)=4, abs(age)=2), Row((age * 2)=10, abs(age)=5)]
... | [
"Projects",
"a",
"set",
"of",
"SQL",
"expressions",
"and",
"returns",
"a",
"new",
":",
"class",
":",
"DataFrame",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1320-L1331 | [
"def",
"selectExpr",
"(",
"self",
",",
"*",
"expr",
")",
":",
"if",
"len",
"(",
"expr",
")",
"==",
"1",
"and",
"isinstance",
"(",
"expr",
"[",
"0",
"]",
",",
"list",
")",
":",
"expr",
"=",
"expr",
"[",
"0",
"]",
"jdf",
"=",
"self",
".",
"_jdf... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.filter | Filters rows using the given condition.
:func:`where` is an alias for :func:`filter`.
:param condition: a :class:`Column` of :class:`types.BooleanType`
or a string of SQL expression.
>>> df.filter(df.age > 3).collect()
[Row(age=5, name=u'Bob')]
>>> df.where(df.age ... | python/pyspark/sql/dataframe.py | def filter(self, condition):
"""Filters rows using the given condition.
:func:`where` is an alias for :func:`filter`.
:param condition: a :class:`Column` of :class:`types.BooleanType`
or a string of SQL expression.
>>> df.filter(df.age > 3).collect()
[Row(age=5, na... | def filter(self, condition):
"""Filters rows using the given condition.
:func:`where` is an alias for :func:`filter`.
:param condition: a :class:`Column` of :class:`types.BooleanType`
or a string of SQL expression.
>>> df.filter(df.age > 3).collect()
[Row(age=5, na... | [
"Filters",
"rows",
"using",
"the",
"given",
"condition",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1335-L1359 | [
"def",
"filter",
"(",
"self",
",",
"condition",
")",
":",
"if",
"isinstance",
"(",
"condition",
",",
"basestring",
")",
":",
"jdf",
"=",
"self",
".",
"_jdf",
".",
"filter",
"(",
"condition",
")",
"elif",
"isinstance",
"(",
"condition",
",",
"Column",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.groupBy | Groups the :class:`DataFrame` using the specified columns,
so we can run aggregation on them. See :class:`GroupedData`
for all the available aggregate functions.
:func:`groupby` is an alias for :func:`groupBy`.
:param cols: list of columns to group by.
Each element should b... | python/pyspark/sql/dataframe.py | def groupBy(self, *cols):
"""Groups the :class:`DataFrame` using the specified columns,
so we can run aggregation on them. See :class:`GroupedData`
for all the available aggregate functions.
:func:`groupby` is an alias for :func:`groupBy`.
:param cols: list of columns to group ... | def groupBy(self, *cols):
"""Groups the :class:`DataFrame` using the specified columns,
so we can run aggregation on them. See :class:`GroupedData`
for all the available aggregate functions.
:func:`groupby` is an alias for :func:`groupBy`.
:param cols: list of columns to group ... | [
"Groups",
"the",
":",
"class",
":",
"DataFrame",
"using",
"the",
"specified",
"columns",
"so",
"we",
"can",
"run",
"aggregation",
"on",
"them",
".",
"See",
":",
"class",
":",
"GroupedData",
"for",
"all",
"the",
"available",
"aggregate",
"functions",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1363-L1384 | [
"def",
"groupBy",
"(",
"self",
",",
"*",
"cols",
")",
":",
"jgd",
"=",
"self",
".",
"_jdf",
".",
"groupBy",
"(",
"self",
".",
"_jcols",
"(",
"*",
"cols",
")",
")",
"from",
"pyspark",
".",
"sql",
".",
"group",
"import",
"GroupedData",
"return",
"Gro... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.union | Return a new :class:`DataFrame` containing union of rows in this and another frame.
This is equivalent to `UNION ALL` in SQL. To do a SQL-style set union
(that does deduplication of elements), use this function followed by :func:`distinct`.
Also as standard in SQL, this function resolves colum... | python/pyspark/sql/dataframe.py | def union(self, other):
""" Return a new :class:`DataFrame` containing union of rows in this and another frame.
This is equivalent to `UNION ALL` in SQL. To do a SQL-style set union
(that does deduplication of elements), use this function followed by :func:`distinct`.
Also as standard ... | def union(self, other):
""" Return a new :class:`DataFrame` containing union of rows in this and another frame.
This is equivalent to `UNION ALL` in SQL. To do a SQL-style set union
(that does deduplication of elements), use this function followed by :func:`distinct`.
Also as standard ... | [
"Return",
"a",
"new",
":",
"class",
":",
"DataFrame",
"containing",
"union",
"of",
"rows",
"in",
"this",
"and",
"another",
"frame",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1444-L1452 | [
"def",
"union",
"(",
"self",
",",
"other",
")",
":",
"return",
"DataFrame",
"(",
"self",
".",
"_jdf",
".",
"union",
"(",
"other",
".",
"_jdf",
")",
",",
"self",
".",
"sql_ctx",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.unionByName | Returns a new :class:`DataFrame` containing union of rows in this and another frame.
This is different from both `UNION ALL` and `UNION DISTINCT` in SQL. To do a SQL-style set
union (that does deduplication of elements), use this function followed by :func:`distinct`.
The difference between th... | python/pyspark/sql/dataframe.py | def unionByName(self, other):
""" Returns a new :class:`DataFrame` containing union of rows in this and another frame.
This is different from both `UNION ALL` and `UNION DISTINCT` in SQL. To do a SQL-style set
union (that does deduplication of elements), use this function followed by :func:`dis... | def unionByName(self, other):
""" Returns a new :class:`DataFrame` containing union of rows in this and another frame.
This is different from both `UNION ALL` and `UNION DISTINCT` in SQL. To do a SQL-style set
union (that does deduplication of elements), use this function followed by :func:`dis... | [
"Returns",
"a",
"new",
":",
"class",
":",
"DataFrame",
"containing",
"union",
"of",
"rows",
"in",
"this",
"and",
"another",
"frame",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1466-L1485 | [
"def",
"unionByName",
"(",
"self",
",",
"other",
")",
":",
"return",
"DataFrame",
"(",
"self",
".",
"_jdf",
".",
"unionByName",
"(",
"other",
".",
"_jdf",
")",
",",
"self",
".",
"sql_ctx",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.intersect | Return a new :class:`DataFrame` containing rows only in
both this frame and another frame.
This is equivalent to `INTERSECT` in SQL. | python/pyspark/sql/dataframe.py | def intersect(self, other):
""" Return a new :class:`DataFrame` containing rows only in
both this frame and another frame.
This is equivalent to `INTERSECT` in SQL.
"""
return DataFrame(self._jdf.intersect(other._jdf), self.sql_ctx) | def intersect(self, other):
""" Return a new :class:`DataFrame` containing rows only in
both this frame and another frame.
This is equivalent to `INTERSECT` in SQL.
"""
return DataFrame(self._jdf.intersect(other._jdf), self.sql_ctx) | [
"Return",
"a",
"new",
":",
"class",
":",
"DataFrame",
"containing",
"rows",
"only",
"in",
"both",
"this",
"frame",
"and",
"another",
"frame",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1488-L1494 | [
"def",
"intersect",
"(",
"self",
",",
"other",
")",
":",
"return",
"DataFrame",
"(",
"self",
".",
"_jdf",
".",
"intersect",
"(",
"other",
".",
"_jdf",
")",
",",
"self",
".",
"sql_ctx",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.intersectAll | Return a new :class:`DataFrame` containing rows in both this dataframe and other
dataframe while preserving duplicates.
This is equivalent to `INTERSECT ALL` in SQL.
>>> df1 = spark.createDataFrame([("a", 1), ("a", 1), ("b", 3), ("c", 4)], ["C1", "C2"])
>>> df2 = spark.createDataFrame([... | python/pyspark/sql/dataframe.py | def intersectAll(self, other):
""" Return a new :class:`DataFrame` containing rows in both this dataframe and other
dataframe while preserving duplicates.
This is equivalent to `INTERSECT ALL` in SQL.
>>> df1 = spark.createDataFrame([("a", 1), ("a", 1), ("b", 3), ("c", 4)], ["C1", "C2"]... | def intersectAll(self, other):
""" Return a new :class:`DataFrame` containing rows in both this dataframe and other
dataframe while preserving duplicates.
This is equivalent to `INTERSECT ALL` in SQL.
>>> df1 = spark.createDataFrame([("a", 1), ("a", 1), ("b", 3), ("c", 4)], ["C1", "C2"]... | [
"Return",
"a",
"new",
":",
"class",
":",
"DataFrame",
"containing",
"rows",
"in",
"both",
"this",
"dataframe",
"and",
"other",
"dataframe",
"while",
"preserving",
"duplicates",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1497-L1516 | [
"def",
"intersectAll",
"(",
"self",
",",
"other",
")",
":",
"return",
"DataFrame",
"(",
"self",
".",
"_jdf",
".",
"intersectAll",
"(",
"other",
".",
"_jdf",
")",
",",
"self",
".",
"sql_ctx",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.subtract | Return a new :class:`DataFrame` containing rows in this frame
but not in another frame.
This is equivalent to `EXCEPT DISTINCT` in SQL. | python/pyspark/sql/dataframe.py | def subtract(self, other):
""" Return a new :class:`DataFrame` containing rows in this frame
but not in another frame.
This is equivalent to `EXCEPT DISTINCT` in SQL.
"""
return DataFrame(getattr(self._jdf, "except")(other._jdf), self.sql_ctx) | def subtract(self, other):
""" Return a new :class:`DataFrame` containing rows in this frame
but not in another frame.
This is equivalent to `EXCEPT DISTINCT` in SQL.
"""
return DataFrame(getattr(self._jdf, "except")(other._jdf), self.sql_ctx) | [
"Return",
"a",
"new",
":",
"class",
":",
"DataFrame",
"containing",
"rows",
"in",
"this",
"frame",
"but",
"not",
"in",
"another",
"frame",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1519-L1526 | [
"def",
"subtract",
"(",
"self",
",",
"other",
")",
":",
"return",
"DataFrame",
"(",
"getattr",
"(",
"self",
".",
"_jdf",
",",
"\"except\"",
")",
"(",
"other",
".",
"_jdf",
")",
",",
"self",
".",
"sql_ctx",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.dropDuplicates | Return a new :class:`DataFrame` with duplicate rows removed,
optionally only considering certain columns.
For a static batch :class:`DataFrame`, it just drops duplicate rows. For a streaming
:class:`DataFrame`, it will keep all data across triggers as intermediate state to drop
duplicat... | python/pyspark/sql/dataframe.py | def dropDuplicates(self, subset=None):
"""Return a new :class:`DataFrame` with duplicate rows removed,
optionally only considering certain columns.
For a static batch :class:`DataFrame`, it just drops duplicate rows. For a streaming
:class:`DataFrame`, it will keep all data across trigg... | def dropDuplicates(self, subset=None):
"""Return a new :class:`DataFrame` with duplicate rows removed,
optionally only considering certain columns.
For a static batch :class:`DataFrame`, it just drops duplicate rows. For a streaming
:class:`DataFrame`, it will keep all data across trigg... | [
"Return",
"a",
"new",
":",
"class",
":",
"DataFrame",
"with",
"duplicate",
"rows",
"removed",
"optionally",
"only",
"considering",
"certain",
"columns",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1529-L1565 | [
"def",
"dropDuplicates",
"(",
"self",
",",
"subset",
"=",
"None",
")",
":",
"if",
"subset",
"is",
"None",
":",
"jdf",
"=",
"self",
".",
"_jdf",
".",
"dropDuplicates",
"(",
")",
"else",
":",
"jdf",
"=",
"self",
".",
"_jdf",
".",
"dropDuplicates",
"(",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.dropna | Returns a new :class:`DataFrame` omitting rows with null values.
:func:`DataFrame.dropna` and :func:`DataFrameNaFunctions.drop` are aliases of each other.
:param how: 'any' or 'all'.
If 'any', drop a row if it contains any nulls.
If 'all', drop a row only if all its values are n... | python/pyspark/sql/dataframe.py | def dropna(self, how='any', thresh=None, subset=None):
"""Returns a new :class:`DataFrame` omitting rows with null values.
:func:`DataFrame.dropna` and :func:`DataFrameNaFunctions.drop` are aliases of each other.
:param how: 'any' or 'all'.
If 'any', drop a row if it contains any nu... | def dropna(self, how='any', thresh=None, subset=None):
"""Returns a new :class:`DataFrame` omitting rows with null values.
:func:`DataFrame.dropna` and :func:`DataFrameNaFunctions.drop` are aliases of each other.
:param how: 'any' or 'all'.
If 'any', drop a row if it contains any nu... | [
"Returns",
"a",
"new",
":",
"class",
":",
"DataFrame",
"omitting",
"rows",
"with",
"null",
"values",
".",
":",
"func",
":",
"DataFrame",
".",
"dropna",
"and",
":",
"func",
":",
"DataFrameNaFunctions",
".",
"drop",
"are",
"aliases",
"of",
"each",
"other",
... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1568-L1600 | [
"def",
"dropna",
"(",
"self",
",",
"how",
"=",
"'any'",
",",
"thresh",
"=",
"None",
",",
"subset",
"=",
"None",
")",
":",
"if",
"how",
"is",
"not",
"None",
"and",
"how",
"not",
"in",
"[",
"'any'",
",",
"'all'",
"]",
":",
"raise",
"ValueError",
"(... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.fillna | Replace null values, alias for ``na.fill()``.
:func:`DataFrame.fillna` and :func:`DataFrameNaFunctions.fill` are aliases of each other.
:param value: int, long, float, string, bool or dict.
Value to replace null values with.
If the value is a dict, then `subset` is ignored and `... | python/pyspark/sql/dataframe.py | def fillna(self, value, subset=None):
"""Replace null values, alias for ``na.fill()``.
:func:`DataFrame.fillna` and :func:`DataFrameNaFunctions.fill` are aliases of each other.
:param value: int, long, float, string, bool or dict.
Value to replace null values with.
If th... | def fillna(self, value, subset=None):
"""Replace null values, alias for ``na.fill()``.
:func:`DataFrame.fillna` and :func:`DataFrameNaFunctions.fill` are aliases of each other.
:param value: int, long, float, string, bool or dict.
Value to replace null values with.
If th... | [
"Replace",
"null",
"values",
"alias",
"for",
"na",
".",
"fill",
"()",
".",
":",
"func",
":",
"DataFrame",
".",
"fillna",
"and",
":",
"func",
":",
"DataFrameNaFunctions",
".",
"fill",
"are",
"aliases",
"of",
"each",
"other",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1603-L1665 | [
"def",
"fillna",
"(",
"self",
",",
"value",
",",
"subset",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"(",
"float",
",",
"int",
",",
"long",
",",
"basestring",
",",
"bool",
",",
"dict",
")",
")",
":",
"raise",
"ValueError"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.replace | Returns a new :class:`DataFrame` replacing a value with another value.
:func:`DataFrame.replace` and :func:`DataFrameNaFunctions.replace` are
aliases of each other.
Values to_replace and value must have the same type and can only be numerics, booleans,
or strings. Value can have None. Wh... | python/pyspark/sql/dataframe.py | def replace(self, to_replace, value=_NoValue, subset=None):
"""Returns a new :class:`DataFrame` replacing a value with another value.
:func:`DataFrame.replace` and :func:`DataFrameNaFunctions.replace` are
aliases of each other.
Values to_replace and value must have the same type and can ... | def replace(self, to_replace, value=_NoValue, subset=None):
"""Returns a new :class:`DataFrame` replacing a value with another value.
:func:`DataFrame.replace` and :func:`DataFrameNaFunctions.replace` are
aliases of each other.
Values to_replace and value must have the same type and can ... | [
"Returns",
"a",
"new",
":",
"class",
":",
"DataFrame",
"replacing",
"a",
"value",
"with",
"another",
"value",
".",
":",
"func",
":",
"DataFrame",
".",
"replace",
"and",
":",
"func",
":",
"DataFrameNaFunctions",
".",
"replace",
"are",
"aliases",
"of",
"each... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1668-L1805 | [
"def",
"replace",
"(",
"self",
",",
"to_replace",
",",
"value",
"=",
"_NoValue",
",",
"subset",
"=",
"None",
")",
":",
"if",
"value",
"is",
"_NoValue",
":",
"if",
"isinstance",
"(",
"to_replace",
",",
"dict",
")",
":",
"value",
"=",
"None",
"else",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.approxQuantile | Calculates the approximate quantiles of numerical columns of a
DataFrame.
The result of this algorithm has the following deterministic bound:
If the DataFrame has N elements and if we request the quantile at
probability `p` up to error `err`, then the algorithm will return
a sam... | python/pyspark/sql/dataframe.py | def approxQuantile(self, col, probabilities, relativeError):
"""
Calculates the approximate quantiles of numerical columns of a
DataFrame.
The result of this algorithm has the following deterministic bound:
If the DataFrame has N elements and if we request the quantile at
... | def approxQuantile(self, col, probabilities, relativeError):
"""
Calculates the approximate quantiles of numerical columns of a
DataFrame.
The result of this algorithm has the following deterministic bound:
If the DataFrame has N elements and if we request the quantile at
... | [
"Calculates",
"the",
"approximate",
"quantiles",
"of",
"numerical",
"columns",
"of",
"a",
"DataFrame",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1808-L1879 | [
"def",
"approxQuantile",
"(",
"self",
",",
"col",
",",
"probabilities",
",",
"relativeError",
")",
":",
"if",
"not",
"isinstance",
"(",
"col",
",",
"(",
"basestring",
",",
"list",
",",
"tuple",
")",
")",
":",
"raise",
"ValueError",
"(",
"\"col should be a ... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.corr | Calculates the correlation of two columns of a DataFrame as a double value.
Currently only supports the Pearson Correlation Coefficient.
:func:`DataFrame.corr` and :func:`DataFrameStatFunctions.corr` are aliases of each other.
:param col1: The name of the first column
:param col2: The n... | python/pyspark/sql/dataframe.py | def corr(self, col1, col2, method=None):
"""
Calculates the correlation of two columns of a DataFrame as a double value.
Currently only supports the Pearson Correlation Coefficient.
:func:`DataFrame.corr` and :func:`DataFrameStatFunctions.corr` are aliases of each other.
:param ... | def corr(self, col1, col2, method=None):
"""
Calculates the correlation of two columns of a DataFrame as a double value.
Currently only supports the Pearson Correlation Coefficient.
:func:`DataFrame.corr` and :func:`DataFrameStatFunctions.corr` are aliases of each other.
:param ... | [
"Calculates",
"the",
"correlation",
"of",
"two",
"columns",
"of",
"a",
"DataFrame",
"as",
"a",
"double",
"value",
".",
"Currently",
"only",
"supports",
"the",
"Pearson",
"Correlation",
"Coefficient",
".",
":",
"func",
":",
"DataFrame",
".",
"corr",
"and",
":... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1882-L1901 | [
"def",
"corr",
"(",
"self",
",",
"col1",
",",
"col2",
",",
"method",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"col1",
",",
"basestring",
")",
":",
"raise",
"ValueError",
"(",
"\"col1 should be a string.\"",
")",
"if",
"not",
"isinstance",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.cov | Calculate the sample covariance for the given columns, specified by their names, as a
double value. :func:`DataFrame.cov` and :func:`DataFrameStatFunctions.cov` are aliases.
:param col1: The name of the first column
:param col2: The name of the second column | python/pyspark/sql/dataframe.py | def cov(self, col1, col2):
"""
Calculate the sample covariance for the given columns, specified by their names, as a
double value. :func:`DataFrame.cov` and :func:`DataFrameStatFunctions.cov` are aliases.
:param col1: The name of the first column
:param col2: The name of the sec... | def cov(self, col1, col2):
"""
Calculate the sample covariance for the given columns, specified by their names, as a
double value. :func:`DataFrame.cov` and :func:`DataFrameStatFunctions.cov` are aliases.
:param col1: The name of the first column
:param col2: The name of the sec... | [
"Calculate",
"the",
"sample",
"covariance",
"for",
"the",
"given",
"columns",
"specified",
"by",
"their",
"names",
"as",
"a",
"double",
"value",
".",
":",
"func",
":",
"DataFrame",
".",
"cov",
"and",
":",
"func",
":",
"DataFrameStatFunctions",
".",
"cov",
... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1904-L1916 | [
"def",
"cov",
"(",
"self",
",",
"col1",
",",
"col2",
")",
":",
"if",
"not",
"isinstance",
"(",
"col1",
",",
"basestring",
")",
":",
"raise",
"ValueError",
"(",
"\"col1 should be a string.\"",
")",
"if",
"not",
"isinstance",
"(",
"col2",
",",
"basestring",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.crosstab | Computes a pair-wise frequency table of the given columns. Also known as a contingency
table. The number of distinct values for each column should be less than 1e4. At most 1e6
non-zero pair frequencies will be returned.
The first column of each row will be the distinct values of `col1` and the ... | python/pyspark/sql/dataframe.py | def crosstab(self, col1, col2):
"""
Computes a pair-wise frequency table of the given columns. Also known as a contingency
table. The number of distinct values for each column should be less than 1e4. At most 1e6
non-zero pair frequencies will be returned.
The first column of eac... | def crosstab(self, col1, col2):
"""
Computes a pair-wise frequency table of the given columns. Also known as a contingency
table. The number of distinct values for each column should be less than 1e4. At most 1e6
non-zero pair frequencies will be returned.
The first column of eac... | [
"Computes",
"a",
"pair",
"-",
"wise",
"frequency",
"table",
"of",
"the",
"given",
"columns",
".",
"Also",
"known",
"as",
"a",
"contingency",
"table",
".",
"The",
"number",
"of",
"distinct",
"values",
"for",
"each",
"column",
"should",
"be",
"less",
"than",... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1919-L1938 | [
"def",
"crosstab",
"(",
"self",
",",
"col1",
",",
"col2",
")",
":",
"if",
"not",
"isinstance",
"(",
"col1",
",",
"basestring",
")",
":",
"raise",
"ValueError",
"(",
"\"col1 should be a string.\"",
")",
"if",
"not",
"isinstance",
"(",
"col2",
",",
"basestri... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.freqItems | Finding frequent items for columns, possibly with false positives. Using the
frequent element count algorithm described in
"https://doi.org/10.1145/762471.762473, proposed by Karp, Schenker, and Papadimitriou".
:func:`DataFrame.freqItems` and :func:`DataFrameStatFunctions.freqItems` are aliases.... | python/pyspark/sql/dataframe.py | def freqItems(self, cols, support=None):
"""
Finding frequent items for columns, possibly with false positives. Using the
frequent element count algorithm described in
"https://doi.org/10.1145/762471.762473, proposed by Karp, Schenker, and Papadimitriou".
:func:`DataFrame.freqIte... | def freqItems(self, cols, support=None):
"""
Finding frequent items for columns, possibly with false positives. Using the
frequent element count algorithm described in
"https://doi.org/10.1145/762471.762473, proposed by Karp, Schenker, and Papadimitriou".
:func:`DataFrame.freqIte... | [
"Finding",
"frequent",
"items",
"for",
"columns",
"possibly",
"with",
"false",
"positives",
".",
"Using",
"the",
"frequent",
"element",
"count",
"algorithm",
"described",
"in",
"https",
":",
"//",
"doi",
".",
"org",
"/",
"10",
".",
"1145",
"/",
"762471",
"... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1941-L1962 | [
"def",
"freqItems",
"(",
"self",
",",
"cols",
",",
"support",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"cols",
",",
"tuple",
")",
":",
"cols",
"=",
"list",
"(",
"cols",
")",
"if",
"not",
"isinstance",
"(",
"cols",
",",
"list",
")",
":",
"r... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.withColumn | Returns a new :class:`DataFrame` by adding a column or replacing the
existing column that has the same name.
The column expression must be an expression over this DataFrame; attempting to add
a column from some other dataframe will raise an error.
:param colName: string, name of the ne... | python/pyspark/sql/dataframe.py | def withColumn(self, colName, col):
"""
Returns a new :class:`DataFrame` by adding a column or replacing the
existing column that has the same name.
The column expression must be an expression over this DataFrame; attempting to add
a column from some other dataframe will raise a... | def withColumn(self, colName, col):
"""
Returns a new :class:`DataFrame` by adding a column or replacing the
existing column that has the same name.
The column expression must be an expression over this DataFrame; attempting to add
a column from some other dataframe will raise a... | [
"Returns",
"a",
"new",
":",
"class",
":",
"DataFrame",
"by",
"adding",
"a",
"column",
"or",
"replacing",
"the",
"existing",
"column",
"that",
"has",
"the",
"same",
"name",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1966-L1987 | [
"def",
"withColumn",
"(",
"self",
",",
"colName",
",",
"col",
")",
":",
"assert",
"isinstance",
"(",
"col",
",",
"Column",
")",
",",
"\"col should be Column\"",
"return",
"DataFrame",
"(",
"self",
".",
"_jdf",
".",
"withColumn",
"(",
"colName",
",",
"col",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.withColumnRenamed | Returns a new :class:`DataFrame` by renaming an existing column.
This is a no-op if schema doesn't contain the given column name.
:param existing: string, name of the existing column to rename.
:param new: string, new name of the column.
>>> df.withColumnRenamed('age', 'age2').collect(... | python/pyspark/sql/dataframe.py | def withColumnRenamed(self, existing, new):
"""Returns a new :class:`DataFrame` by renaming an existing column.
This is a no-op if schema doesn't contain the given column name.
:param existing: string, name of the existing column to rename.
:param new: string, new name of the column.
... | def withColumnRenamed(self, existing, new):
"""Returns a new :class:`DataFrame` by renaming an existing column.
This is a no-op if schema doesn't contain the given column name.
:param existing: string, name of the existing column to rename.
:param new: string, new name of the column.
... | [
"Returns",
"a",
"new",
":",
"class",
":",
"DataFrame",
"by",
"renaming",
"an",
"existing",
"column",
".",
"This",
"is",
"a",
"no",
"-",
"op",
"if",
"schema",
"doesn",
"t",
"contain",
"the",
"given",
"column",
"name",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1991-L2001 | [
"def",
"withColumnRenamed",
"(",
"self",
",",
"existing",
",",
"new",
")",
":",
"return",
"DataFrame",
"(",
"self",
".",
"_jdf",
".",
"withColumnRenamed",
"(",
"existing",
",",
"new",
")",
",",
"self",
".",
"sql_ctx",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.drop | Returns a new :class:`DataFrame` that drops the specified column.
This is a no-op if schema doesn't contain the given column name(s).
:param cols: a string name of the column to drop, or a
:class:`Column` to drop, or a list of string name of the columns to drop.
>>> df.drop('age').... | python/pyspark/sql/dataframe.py | def drop(self, *cols):
"""Returns a new :class:`DataFrame` that drops the specified column.
This is a no-op if schema doesn't contain the given column name(s).
:param cols: a string name of the column to drop, or a
:class:`Column` to drop, or a list of string name of the columns to ... | def drop(self, *cols):
"""Returns a new :class:`DataFrame` that drops the specified column.
This is a no-op if schema doesn't contain the given column name(s).
:param cols: a string name of the column to drop, or a
:class:`Column` to drop, or a list of string name of the columns to ... | [
"Returns",
"a",
"new",
":",
"class",
":",
"DataFrame",
"that",
"drops",
"the",
"specified",
"column",
".",
"This",
"is",
"a",
"no",
"-",
"op",
"if",
"schema",
"doesn",
"t",
"contain",
"the",
"given",
"column",
"name",
"(",
"s",
")",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L2005-L2041 | [
"def",
"drop",
"(",
"self",
",",
"*",
"cols",
")",
":",
"if",
"len",
"(",
"cols",
")",
"==",
"1",
":",
"col",
"=",
"cols",
"[",
"0",
"]",
"if",
"isinstance",
"(",
"col",
",",
"basestring",
")",
":",
"jdf",
"=",
"self",
".",
"_jdf",
".",
"drop... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.toDF | Returns a new class:`DataFrame` that with new specified column names
:param cols: list of new column names (string)
>>> df.toDF('f1', 'f2').collect()
[Row(f1=2, f2=u'Alice'), Row(f1=5, f2=u'Bob')] | python/pyspark/sql/dataframe.py | def toDF(self, *cols):
"""Returns a new class:`DataFrame` that with new specified column names
:param cols: list of new column names (string)
>>> df.toDF('f1', 'f2').collect()
[Row(f1=2, f2=u'Alice'), Row(f1=5, f2=u'Bob')]
"""
jdf = self._jdf.toDF(self._jseq(cols))
... | def toDF(self, *cols):
"""Returns a new class:`DataFrame` that with new specified column names
:param cols: list of new column names (string)
>>> df.toDF('f1', 'f2').collect()
[Row(f1=2, f2=u'Alice'), Row(f1=5, f2=u'Bob')]
"""
jdf = self._jdf.toDF(self._jseq(cols))
... | [
"Returns",
"a",
"new",
"class",
":",
"DataFrame",
"that",
"with",
"new",
"specified",
"column",
"names"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L2044-L2053 | [
"def",
"toDF",
"(",
"self",
",",
"*",
"cols",
")",
":",
"jdf",
"=",
"self",
".",
"_jdf",
".",
"toDF",
"(",
"self",
".",
"_jseq",
"(",
"cols",
")",
")",
"return",
"DataFrame",
"(",
"jdf",
",",
"self",
".",
"sql_ctx",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.transform | Returns a new class:`DataFrame`. Concise syntax for chaining custom transformations.
:param func: a function that takes and returns a class:`DataFrame`.
>>> from pyspark.sql.functions import col
>>> df = spark.createDataFrame([(1, 1.0), (2, 2.0)], ["int", "float"])
>>> def cast_all_to_... | python/pyspark/sql/dataframe.py | def transform(self, func):
"""Returns a new class:`DataFrame`. Concise syntax for chaining custom transformations.
:param func: a function that takes and returns a class:`DataFrame`.
>>> from pyspark.sql.functions import col
>>> df = spark.createDataFrame([(1, 1.0), (2, 2.0)], ["int", ... | def transform(self, func):
"""Returns a new class:`DataFrame`. Concise syntax for chaining custom transformations.
:param func: a function that takes and returns a class:`DataFrame`.
>>> from pyspark.sql.functions import col
>>> df = spark.createDataFrame([(1, 1.0), (2, 2.0)], ["int", ... | [
"Returns",
"a",
"new",
"class",
":",
"DataFrame",
".",
"Concise",
"syntax",
"for",
"chaining",
"custom",
"transformations",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L2056-L2078 | [
"def",
"transform",
"(",
"self",
",",
"func",
")",
":",
"result",
"=",
"func",
"(",
"self",
")",
"assert",
"isinstance",
"(",
"result",
",",
"DataFrame",
")",
",",
"\"Func returned an instance of type [%s], \"",
"\"should have been DataFrame.\"",
"%",
"type",
"(",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame.toPandas | Returns the contents of this :class:`DataFrame` as Pandas ``pandas.DataFrame``.
This is only available if Pandas is installed and available.
.. note:: This method should only be used if the resulting Pandas's DataFrame is expected
to be small, as all the data is loaded into the driver's me... | python/pyspark/sql/dataframe.py | def toPandas(self):
"""
Returns the contents of this :class:`DataFrame` as Pandas ``pandas.DataFrame``.
This is only available if Pandas is installed and available.
.. note:: This method should only be used if the resulting Pandas's DataFrame is expected
to be small, as all... | def toPandas(self):
"""
Returns the contents of this :class:`DataFrame` as Pandas ``pandas.DataFrame``.
This is only available if Pandas is installed and available.
.. note:: This method should only be used if the resulting Pandas's DataFrame is expected
to be small, as all... | [
"Returns",
"the",
"contents",
"of",
"this",
":",
"class",
":",
"DataFrame",
"as",
"Pandas",
"pandas",
".",
"DataFrame",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L2081-L2192 | [
"def",
"toPandas",
"(",
"self",
")",
":",
"from",
"pyspark",
".",
"sql",
".",
"utils",
"import",
"require_minimum_pandas_version",
"require_minimum_pandas_version",
"(",
")",
"import",
"pandas",
"as",
"pd",
"if",
"self",
".",
"sql_ctx",
".",
"_conf",
".",
"pan... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrame._collectAsArrow | Returns all records as a list of ArrowRecordBatches, pyarrow must be installed
and available on driver and worker Python environments.
.. note:: Experimental. | python/pyspark/sql/dataframe.py | def _collectAsArrow(self):
"""
Returns all records as a list of ArrowRecordBatches, pyarrow must be installed
and available on driver and worker Python environments.
.. note:: Experimental.
"""
with SCCallSiteSync(self._sc) as css:
sock_info = self._jdf.colle... | def _collectAsArrow(self):
"""
Returns all records as a list of ArrowRecordBatches, pyarrow must be installed
and available on driver and worker Python environments.
.. note:: Experimental.
"""
with SCCallSiteSync(self._sc) as css:
sock_info = self._jdf.colle... | [
"Returns",
"all",
"records",
"as",
"a",
"list",
"of",
"ArrowRecordBatches",
"pyarrow",
"must",
"be",
"installed",
"and",
"available",
"on",
"driver",
"and",
"worker",
"Python",
"environments",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L2194-L2210 | [
"def",
"_collectAsArrow",
"(",
"self",
")",
":",
"with",
"SCCallSiteSync",
"(",
"self",
".",
"_sc",
")",
"as",
"css",
":",
"sock_info",
"=",
"self",
".",
"_jdf",
".",
"collectAsArrowToPython",
"(",
")",
"# Collect list of un-ordered batches where last element is a l... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | StatCounter.asDict | Returns the :class:`StatCounter` members as a ``dict``.
>>> sc.parallelize([1., 2., 3., 4.]).stats().asDict()
{'count': 4L,
'max': 4.0,
'mean': 2.5,
'min': 1.0,
'stdev': 1.2909944487358056,
'sum': 10.0,
'variance': 1.6666666666666667} | python/pyspark/statcounter.py | def asDict(self, sample=False):
"""Returns the :class:`StatCounter` members as a ``dict``.
>>> sc.parallelize([1., 2., 3., 4.]).stats().asDict()
{'count': 4L,
'max': 4.0,
'mean': 2.5,
'min': 1.0,
'stdev': 1.2909944487358056,
'sum': 10.0,
'va... | def asDict(self, sample=False):
"""Returns the :class:`StatCounter` members as a ``dict``.
>>> sc.parallelize([1., 2., 3., 4.]).stats().asDict()
{'count': 4L,
'max': 4.0,
'mean': 2.5,
'min': 1.0,
'stdev': 1.2909944487358056,
'sum': 10.0,
'va... | [
"Returns",
"the",
":",
"class",
":",
"StatCounter",
"members",
"as",
"a",
"dict",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/statcounter.py#L134-L154 | [
"def",
"asDict",
"(",
"self",
",",
"sample",
"=",
"False",
")",
":",
"return",
"{",
"'count'",
":",
"self",
".",
"count",
"(",
")",
",",
"'mean'",
":",
"self",
".",
"mean",
"(",
")",
",",
"'sum'",
":",
"self",
".",
"sum",
"(",
")",
",",
"'min'"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _list_function_infos | Returns a list of function information via JVM. Sorts wrapped expression infos by name
and returns them. | sql/gen-sql-markdown.py | def _list_function_infos(jvm):
"""
Returns a list of function information via JVM. Sorts wrapped expression infos by name
and returns them.
"""
jinfos = jvm.org.apache.spark.sql.api.python.PythonSQLUtils.listBuiltinFunctionInfos()
infos = []
for jinfo in jinfos:
name = jinfo.getName... | def _list_function_infos(jvm):
"""
Returns a list of function information via JVM. Sorts wrapped expression infos by name
and returns them.
"""
jinfos = jvm.org.apache.spark.sql.api.python.PythonSQLUtils.listBuiltinFunctionInfos()
infos = []
for jinfo in jinfos:
name = jinfo.getName... | [
"Returns",
"a",
"list",
"of",
"function",
"information",
"via",
"JVM",
".",
"Sorts",
"wrapped",
"expression",
"infos",
"by",
"name",
"and",
"returns",
"them",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/sql/gen-sql-markdown.py#L26-L47 | [
"def",
"_list_function_infos",
"(",
"jvm",
")",
":",
"jinfos",
"=",
"jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",
"sql",
".",
"api",
".",
"python",
".",
"PythonSQLUtils",
".",
"listBuiltinFunctionInfos",
"(",
")",
"infos",
"=",
"[",
"]",
"for",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _make_pretty_usage | Makes the usage description pretty and returns a formatted string if `usage`
is not an empty string. Otherwise, returns None. | sql/gen-sql-markdown.py | def _make_pretty_usage(usage):
"""
Makes the usage description pretty and returns a formatted string if `usage`
is not an empty string. Otherwise, returns None.
"""
if usage is not None and usage.strip() != "":
usage = "\n".join(map(lambda u: u.strip(), usage.split("\n")))
return "%... | def _make_pretty_usage(usage):
"""
Makes the usage description pretty and returns a formatted string if `usage`
is not an empty string. Otherwise, returns None.
"""
if usage is not None and usage.strip() != "":
usage = "\n".join(map(lambda u: u.strip(), usage.split("\n")))
return "%... | [
"Makes",
"the",
"usage",
"description",
"pretty",
"and",
"returns",
"a",
"formatted",
"string",
"if",
"usage",
"is",
"not",
"an",
"empty",
"string",
".",
"Otherwise",
"returns",
"None",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/sql/gen-sql-markdown.py#L50-L58 | [
"def",
"_make_pretty_usage",
"(",
"usage",
")",
":",
"if",
"usage",
"is",
"not",
"None",
"and",
"usage",
".",
"strip",
"(",
")",
"!=",
"\"\"",
":",
"usage",
"=",
"\"\\n\"",
".",
"join",
"(",
"map",
"(",
"lambda",
"u",
":",
"u",
".",
"strip",
"(",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _make_pretty_arguments | Makes the arguments description pretty and returns a formatted string if `arguments`
starts with the argument prefix. Otherwise, returns None.
Expected input:
Arguments:
* arg0 - ...
...
* arg0 - ...
...
Expected output:
**Arguments:**
* ar... | sql/gen-sql-markdown.py | def _make_pretty_arguments(arguments):
"""
Makes the arguments description pretty and returns a formatted string if `arguments`
starts with the argument prefix. Otherwise, returns None.
Expected input:
Arguments:
* arg0 - ...
...
* arg0 - ...
...... | def _make_pretty_arguments(arguments):
"""
Makes the arguments description pretty and returns a formatted string if `arguments`
starts with the argument prefix. Otherwise, returns None.
Expected input:
Arguments:
* arg0 - ...
...
* arg0 - ...
...... | [
"Makes",
"the",
"arguments",
"description",
"pretty",
"and",
"returns",
"a",
"formatted",
"string",
"if",
"arguments",
"starts",
"with",
"the",
"argument",
"prefix",
".",
"Otherwise",
"returns",
"None",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/sql/gen-sql-markdown.py#L61-L86 | [
"def",
"_make_pretty_arguments",
"(",
"arguments",
")",
":",
"if",
"arguments",
".",
"startswith",
"(",
"\"\\n Arguments:\"",
")",
":",
"arguments",
"=",
"\"\\n\"",
".",
"join",
"(",
"map",
"(",
"lambda",
"u",
":",
"u",
"[",
"6",
":",
"]",
",",
"argum... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _make_pretty_examples | Makes the examples description pretty and returns a formatted string if `examples`
starts with the example prefix. Otherwise, returns None.
Expected input:
Examples:
> SELECT ...;
...
> SELECT ...;
...
Expected output:
**Examples:**
```
> SEL... | sql/gen-sql-markdown.py | def _make_pretty_examples(examples):
"""
Makes the examples description pretty and returns a formatted string if `examples`
starts with the example prefix. Otherwise, returns None.
Expected input:
Examples:
> SELECT ...;
...
> SELECT ...;
...
Expe... | def _make_pretty_examples(examples):
"""
Makes the examples description pretty and returns a formatted string if `examples`
starts with the example prefix. Otherwise, returns None.
Expected input:
Examples:
> SELECT ...;
...
> SELECT ...;
...
Expe... | [
"Makes",
"the",
"examples",
"description",
"pretty",
"and",
"returns",
"a",
"formatted",
"string",
"if",
"examples",
"starts",
"with",
"the",
"example",
"prefix",
".",
"Otherwise",
"returns",
"None",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/sql/gen-sql-markdown.py#L89-L116 | [
"def",
"_make_pretty_examples",
"(",
"examples",
")",
":",
"if",
"examples",
".",
"startswith",
"(",
"\"\\n Examples:\"",
")",
":",
"examples",
"=",
"\"\\n\"",
".",
"join",
"(",
"map",
"(",
"lambda",
"u",
":",
"u",
"[",
"6",
":",
"]",
",",
"examples",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _make_pretty_note | Makes the note description pretty and returns a formatted string if `note` is not
an empty string. Otherwise, returns None.
Expected input:
...
Expected output:
**Note:**
... | sql/gen-sql-markdown.py | def _make_pretty_note(note):
"""
Makes the note description pretty and returns a formatted string if `note` is not
an empty string. Otherwise, returns None.
Expected input:
...
Expected output:
**Note:**
...
"""
if note != "":
note = "\n".join(map(lambda n: n[4:... | def _make_pretty_note(note):
"""
Makes the note description pretty and returns a formatted string if `note` is not
an empty string. Otherwise, returns None.
Expected input:
...
Expected output:
**Note:**
...
"""
if note != "":
note = "\n".join(map(lambda n: n[4:... | [
"Makes",
"the",
"note",
"description",
"pretty",
"and",
"returns",
"a",
"formatted",
"string",
"if",
"note",
"is",
"not",
"an",
"empty",
"string",
".",
"Otherwise",
"returns",
"None",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/sql/gen-sql-markdown.py#L119-L137 | [
"def",
"_make_pretty_note",
"(",
"note",
")",
":",
"if",
"note",
"!=",
"\"\"",
":",
"note",
"=",
"\"\\n\"",
".",
"join",
"(",
"map",
"(",
"lambda",
"n",
":",
"n",
"[",
"4",
":",
"]",
",",
"note",
".",
"split",
"(",
"\"\\n\"",
")",
")",
")",
"re... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _make_pretty_deprecated | Makes the deprecated description pretty and returns a formatted string if `deprecated`
is not an empty string. Otherwise, returns None.
Expected input:
...
Expected output:
**Deprecated:**
... | sql/gen-sql-markdown.py | def _make_pretty_deprecated(deprecated):
"""
Makes the deprecated description pretty and returns a formatted string if `deprecated`
is not an empty string. Otherwise, returns None.
Expected input:
...
Expected output:
**Deprecated:**
...
"""
if deprecated != "":
... | def _make_pretty_deprecated(deprecated):
"""
Makes the deprecated description pretty and returns a formatted string if `deprecated`
is not an empty string. Otherwise, returns None.
Expected input:
...
Expected output:
**Deprecated:**
...
"""
if deprecated != "":
... | [
"Makes",
"the",
"deprecated",
"description",
"pretty",
"and",
"returns",
"a",
"formatted",
"string",
"if",
"deprecated",
"is",
"not",
"an",
"empty",
"string",
".",
"Otherwise",
"returns",
"None",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/sql/gen-sql-markdown.py#L140-L158 | [
"def",
"_make_pretty_deprecated",
"(",
"deprecated",
")",
":",
"if",
"deprecated",
"!=",
"\"\"",
":",
"deprecated",
"=",
"\"\\n\"",
".",
"join",
"(",
"map",
"(",
"lambda",
"n",
":",
"n",
"[",
"4",
":",
"]",
",",
"deprecated",
".",
"split",
"(",
"\"\\n\... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | generate_sql_markdown | Generates a markdown file after listing the function information. The output file
is created in `path`.
Expected output:
### NAME
USAGE
**Arguments:**
ARGUMENTS
**Examples:**
```
EXAMPLES
```
**Note:**
NOTE
**Since:** SINCE
**Deprecated:**
DEPRECATE... | sql/gen-sql-markdown.py | def generate_sql_markdown(jvm, path):
"""
Generates a markdown file after listing the function information. The output file
is created in `path`.
Expected output:
### NAME
USAGE
**Arguments:**
ARGUMENTS
**Examples:**
```
EXAMPLES
```
**Note:**
NOTE
**... | def generate_sql_markdown(jvm, path):
"""
Generates a markdown file after listing the function information. The output file
is created in `path`.
Expected output:
### NAME
USAGE
**Arguments:**
ARGUMENTS
**Examples:**
```
EXAMPLES
```
**Note:**
NOTE
**... | [
"Generates",
"a",
"markdown",
"file",
"after",
"listing",
"the",
"function",
"information",
".",
"The",
"output",
"file",
"is",
"created",
"in",
"path",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/sql/gen-sql-markdown.py#L161-L218 | [
"def",
"generate_sql_markdown",
"(",
"jvm",
",",
"path",
")",
":",
"with",
"open",
"(",
"path",
",",
"'w'",
")",
"as",
"mdfile",
":",
"for",
"info",
"in",
"_list_function_infos",
"(",
"jvm",
")",
":",
"name",
"=",
"info",
".",
"name",
"usage",
"=",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | LogisticRegressionModel.predict | Predict values for a single data point or an RDD of points
using the model trained. | python/pyspark/mllib/classification.py | def predict(self, x):
"""
Predict values for a single data point or an RDD of points
using the model trained.
"""
if isinstance(x, RDD):
return x.map(lambda v: self.predict(v))
x = _convert_to_vector(x)
if self.numClasses == 2:
margin = se... | def predict(self, x):
"""
Predict values for a single data point or an RDD of points
using the model trained.
"""
if isinstance(x, RDD):
return x.map(lambda v: self.predict(v))
x = _convert_to_vector(x)
if self.numClasses == 2:
margin = se... | [
"Predict",
"values",
"for",
"a",
"single",
"data",
"point",
"or",
"an",
"RDD",
"of",
"points",
"using",
"the",
"model",
"trained",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/classification.py#L195-L231 | [
"def",
"predict",
"(",
"self",
",",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"RDD",
")",
":",
"return",
"x",
".",
"map",
"(",
"lambda",
"v",
":",
"self",
".",
"predict",
"(",
"v",
")",
")",
"x",
"=",
"_convert_to_vector",
"(",
"x",
")"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | LogisticRegressionModel.save | Save this model to the given path. | python/pyspark/mllib/classification.py | def save(self, sc, path):
"""
Save this model to the given path.
"""
java_model = sc._jvm.org.apache.spark.mllib.classification.LogisticRegressionModel(
_py2java(sc, self._coeff), self.intercept, self.numFeatures, self.numClasses)
java_model.save(sc._jsc.sc(), path) | def save(self, sc, path):
"""
Save this model to the given path.
"""
java_model = sc._jvm.org.apache.spark.mllib.classification.LogisticRegressionModel(
_py2java(sc, self._coeff), self.intercept, self.numFeatures, self.numClasses)
java_model.save(sc._jsc.sc(), path) | [
"Save",
"this",
"model",
"to",
"the",
"given",
"path",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/classification.py#L234-L240 | [
"def",
"save",
"(",
"self",
",",
"sc",
",",
"path",
")",
":",
"java_model",
"=",
"sc",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",
"mllib",
".",
"classification",
".",
"LogisticRegressionModel",
"(",
"_py2java",
"(",
"sc",
",",
"self",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | LogisticRegressionWithLBFGS.train | Train a logistic regression model on the given data.
:param data:
The training data, an RDD of LabeledPoint.
:param iterations:
The number of iterations.
(default: 100)
:param initialWeights:
The initial weights.
(default: None)
:param r... | python/pyspark/mllib/classification.py | def train(cls, data, iterations=100, initialWeights=None, regParam=0.0, regType="l2",
intercept=False, corrections=10, tolerance=1e-6, validateData=True, numClasses=2):
"""
Train a logistic regression model on the given data.
:param data:
The training data, an RDD of Lab... | def train(cls, data, iterations=100, initialWeights=None, regParam=0.0, regType="l2",
intercept=False, corrections=10, tolerance=1e-6, validateData=True, numClasses=2):
"""
Train a logistic regression model on the given data.
:param data:
The training data, an RDD of Lab... | [
"Train",
"a",
"logistic",
"regression",
"model",
"on",
"the",
"given",
"data",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/classification.py#L332-L400 | [
"def",
"train",
"(",
"cls",
",",
"data",
",",
"iterations",
"=",
"100",
",",
"initialWeights",
"=",
"None",
",",
"regParam",
"=",
"0.0",
",",
"regType",
"=",
"\"l2\"",
",",
"intercept",
"=",
"False",
",",
"corrections",
"=",
"10",
",",
"tolerance",
"="... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SVMModel.predict | Predict values for a single data point or an RDD of points
using the model trained. | python/pyspark/mllib/classification.py | def predict(self, x):
"""
Predict values for a single data point or an RDD of points
using the model trained.
"""
if isinstance(x, RDD):
return x.map(lambda v: self.predict(v))
x = _convert_to_vector(x)
margin = self.weights.dot(x) + self.intercept
... | def predict(self, x):
"""
Predict values for a single data point or an RDD of points
using the model trained.
"""
if isinstance(x, RDD):
return x.map(lambda v: self.predict(v))
x = _convert_to_vector(x)
margin = self.weights.dot(x) + self.intercept
... | [
"Predict",
"values",
"for",
"a",
"single",
"data",
"point",
"or",
"an",
"RDD",
"of",
"points",
"using",
"the",
"model",
"trained",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/classification.py#L460-L473 | [
"def",
"predict",
"(",
"self",
",",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"RDD",
")",
":",
"return",
"x",
".",
"map",
"(",
"lambda",
"v",
":",
"self",
".",
"predict",
"(",
"v",
")",
")",
"x",
"=",
"_convert_to_vector",
"(",
"x",
")"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SVMModel.save | Save this model to the given path. | python/pyspark/mllib/classification.py | def save(self, sc, path):
"""
Save this model to the given path.
"""
java_model = sc._jvm.org.apache.spark.mllib.classification.SVMModel(
_py2java(sc, self._coeff), self.intercept)
java_model.save(sc._jsc.sc(), path) | def save(self, sc, path):
"""
Save this model to the given path.
"""
java_model = sc._jvm.org.apache.spark.mllib.classification.SVMModel(
_py2java(sc, self._coeff), self.intercept)
java_model.save(sc._jsc.sc(), path) | [
"Save",
"this",
"model",
"to",
"the",
"given",
"path",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/classification.py#L476-L482 | [
"def",
"save",
"(",
"self",
",",
"sc",
",",
"path",
")",
":",
"java_model",
"=",
"sc",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",
"mllib",
".",
"classification",
".",
"SVMModel",
"(",
"_py2java",
"(",
"sc",
",",
"self",
".",
"_coeff... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SVMModel.load | Load a model from the given path. | python/pyspark/mllib/classification.py | def load(cls, sc, path):
"""
Load a model from the given path.
"""
java_model = sc._jvm.org.apache.spark.mllib.classification.SVMModel.load(
sc._jsc.sc(), path)
weights = _java2py(sc, java_model.weights())
intercept = java_model.intercept()
threshold =... | def load(cls, sc, path):
"""
Load a model from the given path.
"""
java_model = sc._jvm.org.apache.spark.mllib.classification.SVMModel.load(
sc._jsc.sc(), path)
weights = _java2py(sc, java_model.weights())
intercept = java_model.intercept()
threshold =... | [
"Load",
"a",
"model",
"from",
"the",
"given",
"path",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/classification.py#L486-L497 | [
"def",
"load",
"(",
"cls",
",",
"sc",
",",
"path",
")",
":",
"java_model",
"=",
"sc",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",
"mllib",
".",
"classification",
".",
"SVMModel",
".",
"load",
"(",
"sc",
".",
"_jsc",
".",
"sc",
"(",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | NaiveBayes.train | Train a Naive Bayes model given an RDD of (label, features)
vectors.
This is the Multinomial NB (U{http://tinyurl.com/lsdw6p}) which
can handle all kinds of discrete data. For example, by
converting documents into TF-IDF vectors, it can be used for
document classification. By m... | python/pyspark/mllib/classification.py | def train(cls, data, lambda_=1.0):
"""
Train a Naive Bayes model given an RDD of (label, features)
vectors.
This is the Multinomial NB (U{http://tinyurl.com/lsdw6p}) which
can handle all kinds of discrete data. For example, by
converting documents into TF-IDF vectors, i... | def train(cls, data, lambda_=1.0):
"""
Train a Naive Bayes model given an RDD of (label, features)
vectors.
This is the Multinomial NB (U{http://tinyurl.com/lsdw6p}) which
can handle all kinds of discrete data. For example, by
converting documents into TF-IDF vectors, i... | [
"Train",
"a",
"Naive",
"Bayes",
"model",
"given",
"an",
"RDD",
"of",
"(",
"label",
"features",
")",
"vectors",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/classification.py#L657-L679 | [
"def",
"train",
"(",
"cls",
",",
"data",
",",
"lambda_",
"=",
"1.0",
")",
":",
"first",
"=",
"data",
".",
"first",
"(",
")",
"if",
"not",
"isinstance",
"(",
"first",
",",
"LabeledPoint",
")",
":",
"raise",
"ValueError",
"(",
"\"`data` should be an RDD of... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | heappush | Push item onto heap, maintaining the heap invariant. | python/pyspark/heapq3.py | def heappush(heap, item):
"""Push item onto heap, maintaining the heap invariant."""
heap.append(item)
_siftdown(heap, 0, len(heap)-1) | def heappush(heap, item):
"""Push item onto heap, maintaining the heap invariant."""
heap.append(item)
_siftdown(heap, 0, len(heap)-1) | [
"Push",
"item",
"onto",
"heap",
"maintaining",
"the",
"heap",
"invariant",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L411-L414 | [
"def",
"heappush",
"(",
"heap",
",",
"item",
")",
":",
"heap",
".",
"append",
"(",
"item",
")",
"_siftdown",
"(",
"heap",
",",
"0",
",",
"len",
"(",
"heap",
")",
"-",
"1",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | heappop | Pop the smallest item off the heap, maintaining the heap invariant. | python/pyspark/heapq3.py | def heappop(heap):
"""Pop the smallest item off the heap, maintaining the heap invariant."""
lastelt = heap.pop() # raises appropriate IndexError if heap is empty
if heap:
returnitem = heap[0]
heap[0] = lastelt
_siftup(heap, 0)
return returnitem
return lastelt | def heappop(heap):
"""Pop the smallest item off the heap, maintaining the heap invariant."""
lastelt = heap.pop() # raises appropriate IndexError if heap is empty
if heap:
returnitem = heap[0]
heap[0] = lastelt
_siftup(heap, 0)
return returnitem
return lastelt | [
"Pop",
"the",
"smallest",
"item",
"off",
"the",
"heap",
"maintaining",
"the",
"heap",
"invariant",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L416-L424 | [
"def",
"heappop",
"(",
"heap",
")",
":",
"lastelt",
"=",
"heap",
".",
"pop",
"(",
")",
"# raises appropriate IndexError if heap is empty",
"if",
"heap",
":",
"returnitem",
"=",
"heap",
"[",
"0",
"]",
"heap",
"[",
"0",
"]",
"=",
"lastelt",
"_siftup",
"(",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | heapreplace | Pop and return the current smallest value, and add the new item.
This is more efficient than heappop() followed by heappush(), and can be
more appropriate when using a fixed-size heap. Note that the value
returned may be larger than item! That constrains reasonable uses of
this routine unless written... | python/pyspark/heapq3.py | def heapreplace(heap, item):
"""Pop and return the current smallest value, and add the new item.
This is more efficient than heappop() followed by heappush(), and can be
more appropriate when using a fixed-size heap. Note that the value
returned may be larger than item! That constrains reasonable use... | def heapreplace(heap, item):
"""Pop and return the current smallest value, and add the new item.
This is more efficient than heappop() followed by heappush(), and can be
more appropriate when using a fixed-size heap. Note that the value
returned may be larger than item! That constrains reasonable use... | [
"Pop",
"and",
"return",
"the",
"current",
"smallest",
"value",
"and",
"add",
"the",
"new",
"item",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L426-L440 | [
"def",
"heapreplace",
"(",
"heap",
",",
"item",
")",
":",
"returnitem",
"=",
"heap",
"[",
"0",
"]",
"# raises appropriate IndexError if heap is empty",
"heap",
"[",
"0",
"]",
"=",
"item",
"_siftup",
"(",
"heap",
",",
"0",
")",
"return",
"returnitem"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | heappushpop | Fast version of a heappush followed by a heappop. | python/pyspark/heapq3.py | def heappushpop(heap, item):
"""Fast version of a heappush followed by a heappop."""
if heap and heap[0] < item:
item, heap[0] = heap[0], item
_siftup(heap, 0)
return item | def heappushpop(heap, item):
"""Fast version of a heappush followed by a heappop."""
if heap and heap[0] < item:
item, heap[0] = heap[0], item
_siftup(heap, 0)
return item | [
"Fast",
"version",
"of",
"a",
"heappush",
"followed",
"by",
"a",
"heappop",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L442-L447 | [
"def",
"heappushpop",
"(",
"heap",
",",
"item",
")",
":",
"if",
"heap",
"and",
"heap",
"[",
"0",
"]",
"<",
"item",
":",
"item",
",",
"heap",
"[",
"0",
"]",
"=",
"heap",
"[",
"0",
"]",
",",
"item",
"_siftup",
"(",
"heap",
",",
"0",
")",
"retur... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | heapify | Transform list into a heap, in-place, in O(len(x)) time. | python/pyspark/heapq3.py | def heapify(x):
"""Transform list into a heap, in-place, in O(len(x)) time."""
n = len(x)
# Transform bottom-up. The largest index there's any point to looking at
# is the largest with a child index in-range, so must have 2*i + 1 < n,
# or i < (n-1)/2. If n is even = 2*j, this is (2*j-1)/2 = j-1/2... | def heapify(x):
"""Transform list into a heap, in-place, in O(len(x)) time."""
n = len(x)
# Transform bottom-up. The largest index there's any point to looking at
# is the largest with a child index in-range, so must have 2*i + 1 < n,
# or i < (n-1)/2. If n is even = 2*j, this is (2*j-1)/2 = j-1/2... | [
"Transform",
"list",
"into",
"a",
"heap",
"in",
"-",
"place",
"in",
"O",
"(",
"len",
"(",
"x",
"))",
"time",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L449-L458 | [
"def",
"heapify",
"(",
"x",
")",
":",
"n",
"=",
"len",
"(",
"x",
")",
"# Transform bottom-up. The largest index there's any point to looking at",
"# is the largest with a child index in-range, so must have 2*i + 1 < n,",
"# or i < (n-1)/2. If n is even = 2*j, this is (2*j-1)/2 = j-1/2 ... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _heappop_max | Maxheap version of a heappop. | python/pyspark/heapq3.py | def _heappop_max(heap):
"""Maxheap version of a heappop."""
lastelt = heap.pop() # raises appropriate IndexError if heap is empty
if heap:
returnitem = heap[0]
heap[0] = lastelt
_siftup_max(heap, 0)
return returnitem
return lastelt | def _heappop_max(heap):
"""Maxheap version of a heappop."""
lastelt = heap.pop() # raises appropriate IndexError if heap is empty
if heap:
returnitem = heap[0]
heap[0] = lastelt
_siftup_max(heap, 0)
return returnitem
return lastelt | [
"Maxheap",
"version",
"of",
"a",
"heappop",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L460-L468 | [
"def",
"_heappop_max",
"(",
"heap",
")",
":",
"lastelt",
"=",
"heap",
".",
"pop",
"(",
")",
"# raises appropriate IndexError if heap is empty",
"if",
"heap",
":",
"returnitem",
"=",
"heap",
"[",
"0",
"]",
"heap",
"[",
"0",
"]",
"=",
"lastelt",
"_siftup_max",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _heapreplace_max | Maxheap version of a heappop followed by a heappush. | python/pyspark/heapq3.py | def _heapreplace_max(heap, item):
"""Maxheap version of a heappop followed by a heappush."""
returnitem = heap[0] # raises appropriate IndexError if heap is empty
heap[0] = item
_siftup_max(heap, 0)
return returnitem | def _heapreplace_max(heap, item):
"""Maxheap version of a heappop followed by a heappush."""
returnitem = heap[0] # raises appropriate IndexError if heap is empty
heap[0] = item
_siftup_max(heap, 0)
return returnitem | [
"Maxheap",
"version",
"of",
"a",
"heappop",
"followed",
"by",
"a",
"heappush",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L470-L475 | [
"def",
"_heapreplace_max",
"(",
"heap",
",",
"item",
")",
":",
"returnitem",
"=",
"heap",
"[",
"0",
"]",
"# raises appropriate IndexError if heap is empty",
"heap",
"[",
"0",
"]",
"=",
"item",
"_siftup_max",
"(",
"heap",
",",
"0",
")",
"return",
"returnitem"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _heapify_max | Transform list into a maxheap, in-place, in O(len(x)) time. | python/pyspark/heapq3.py | def _heapify_max(x):
"""Transform list into a maxheap, in-place, in O(len(x)) time."""
n = len(x)
for i in reversed(range(n//2)):
_siftup_max(x, i) | def _heapify_max(x):
"""Transform list into a maxheap, in-place, in O(len(x)) time."""
n = len(x)
for i in reversed(range(n//2)):
_siftup_max(x, i) | [
"Transform",
"list",
"into",
"a",
"maxheap",
"in",
"-",
"place",
"in",
"O",
"(",
"len",
"(",
"x",
"))",
"time",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L477-L481 | [
"def",
"_heapify_max",
"(",
"x",
")",
":",
"n",
"=",
"len",
"(",
"x",
")",
"for",
"i",
"in",
"reversed",
"(",
"range",
"(",
"n",
"//",
"2",
")",
")",
":",
"_siftup_max",
"(",
"x",
",",
"i",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _siftdown_max | Maxheap variant of _siftdown | python/pyspark/heapq3.py | def _siftdown_max(heap, startpos, pos):
'Maxheap variant of _siftdown'
newitem = heap[pos]
# Follow the path to the root, moving parents down until finding a place
# newitem fits.
while pos > startpos:
parentpos = (pos - 1) >> 1
parent = heap[parentpos]
if parent < newitem:
... | def _siftdown_max(heap, startpos, pos):
'Maxheap variant of _siftdown'
newitem = heap[pos]
# Follow the path to the root, moving parents down until finding a place
# newitem fits.
while pos > startpos:
parentpos = (pos - 1) >> 1
parent = heap[parentpos]
if parent < newitem:
... | [
"Maxheap",
"variant",
"of",
"_siftdown"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L559-L572 | [
"def",
"_siftdown_max",
"(",
"heap",
",",
"startpos",
",",
"pos",
")",
":",
"newitem",
"=",
"heap",
"[",
"pos",
"]",
"# Follow the path to the root, moving parents down until finding a place",
"# newitem fits.",
"while",
"pos",
">",
"startpos",
":",
"parentpos",
"=",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _siftup_max | Maxheap variant of _siftup | python/pyspark/heapq3.py | def _siftup_max(heap, pos):
'Maxheap variant of _siftup'
endpos = len(heap)
startpos = pos
newitem = heap[pos]
# Bubble up the larger child until hitting a leaf.
childpos = 2*pos + 1 # leftmost child position
while childpos < endpos:
# Set childpos to index of larger child.
... | def _siftup_max(heap, pos):
'Maxheap variant of _siftup'
endpos = len(heap)
startpos = pos
newitem = heap[pos]
# Bubble up the larger child until hitting a leaf.
childpos = 2*pos + 1 # leftmost child position
while childpos < endpos:
# Set childpos to index of larger child.
... | [
"Maxheap",
"variant",
"of",
"_siftup"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L574-L593 | [
"def",
"_siftup_max",
"(",
"heap",
",",
"pos",
")",
":",
"endpos",
"=",
"len",
"(",
"heap",
")",
"startpos",
"=",
"pos",
"newitem",
"=",
"heap",
"[",
"pos",
"]",
"# Bubble up the larger child until hitting a leaf.",
"childpos",
"=",
"2",
"*",
"pos",
"+",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | merge | Merge multiple sorted inputs into a single sorted output.
Similar to sorted(itertools.chain(*iterables)) but returns a generator,
does not pull the data into memory all at once, and assumes that each of
the input streams is already sorted (smallest to largest).
>>> list(merge([1,3,5,7], [0,2,4,8], [5,... | python/pyspark/heapq3.py | def merge(iterables, key=None, reverse=False):
'''Merge multiple sorted inputs into a single sorted output.
Similar to sorted(itertools.chain(*iterables)) but returns a generator,
does not pull the data into memory all at once, and assumes that each of
the input streams is already sorted (smallest to l... | def merge(iterables, key=None, reverse=False):
'''Merge multiple sorted inputs into a single sorted output.
Similar to sorted(itertools.chain(*iterables)) but returns a generator,
does not pull the data into memory all at once, and assumes that each of
the input streams is already sorted (smallest to l... | [
"Merge",
"multiple",
"sorted",
"inputs",
"into",
"a",
"single",
"sorted",
"output",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L595-L673 | [
"def",
"merge",
"(",
"iterables",
",",
"key",
"=",
"None",
",",
"reverse",
"=",
"False",
")",
":",
"h",
"=",
"[",
"]",
"h_append",
"=",
"h",
".",
"append",
"if",
"reverse",
":",
"_heapify",
"=",
"_heapify_max",
"_heappop",
"=",
"_heappop_max",
"_heapre... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | nsmallest | Find the n smallest elements in a dataset.
Equivalent to: sorted(iterable, key=key)[:n] | python/pyspark/heapq3.py | def nsmallest(n, iterable, key=None):
"""Find the n smallest elements in a dataset.
Equivalent to: sorted(iterable, key=key)[:n]
"""
# Short-cut for n==1 is to use min()
if n == 1:
it = iter(iterable)
sentinel = object()
if key is None:
result = min(it, default... | def nsmallest(n, iterable, key=None):
"""Find the n smallest elements in a dataset.
Equivalent to: sorted(iterable, key=key)[:n]
"""
# Short-cut for n==1 is to use min()
if n == 1:
it = iter(iterable)
sentinel = object()
if key is None:
result = min(it, default... | [
"Find",
"the",
"n",
"smallest",
"elements",
"in",
"a",
"dataset",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L742-L803 | [
"def",
"nsmallest",
"(",
"n",
",",
"iterable",
",",
"key",
"=",
"None",
")",
":",
"# Short-cut for n==1 is to use min()",
"if",
"n",
"==",
"1",
":",
"it",
"=",
"iter",
"(",
"iterable",
")",
"sentinel",
"=",
"object",
"(",
")",
"if",
"key",
"is",
"None"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | nlargest | Find the n largest elements in a dataset.
Equivalent to: sorted(iterable, key=key, reverse=True)[:n] | python/pyspark/heapq3.py | def nlargest(n, iterable, key=None):
"""Find the n largest elements in a dataset.
Equivalent to: sorted(iterable, key=key, reverse=True)[:n]
"""
# Short-cut for n==1 is to use max()
if n == 1:
it = iter(iterable)
sentinel = object()
if key is None:
result = max... | def nlargest(n, iterable, key=None):
"""Find the n largest elements in a dataset.
Equivalent to: sorted(iterable, key=key, reverse=True)[:n]
"""
# Short-cut for n==1 is to use max()
if n == 1:
it = iter(iterable)
sentinel = object()
if key is None:
result = max... | [
"Find",
"the",
"n",
"largest",
"elements",
"in",
"a",
"dataset",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L805-L864 | [
"def",
"nlargest",
"(",
"n",
",",
"iterable",
",",
"key",
"=",
"None",
")",
":",
"# Short-cut for n==1 is to use max()",
"if",
"n",
"==",
"1",
":",
"it",
"=",
"iter",
"(",
"iterable",
")",
"sentinel",
"=",
"object",
"(",
")",
"if",
"key",
"is",
"None",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Correlation.corr | Compute the correlation matrix with specified method using dataset.
:param dataset:
A Dataset or a DataFrame.
:param column:
The name of the column of vectors for which the correlation coefficient needs
to be computed. This must be a column of the dataset, and it must cont... | python/pyspark/ml/stat.py | def corr(dataset, column, method="pearson"):
"""
Compute the correlation matrix with specified method using dataset.
:param dataset:
A Dataset or a DataFrame.
:param column:
The name of the column of vectors for which the correlation coefficient needs
to be... | def corr(dataset, column, method="pearson"):
"""
Compute the correlation matrix with specified method using dataset.
:param dataset:
A Dataset or a DataFrame.
:param column:
The name of the column of vectors for which the correlation coefficient needs
to be... | [
"Compute",
"the",
"correlation",
"matrix",
"with",
"specified",
"method",
"using",
"dataset",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/stat.py#L95-L136 | [
"def",
"corr",
"(",
"dataset",
",",
"column",
",",
"method",
"=",
"\"pearson\"",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"javaCorrObj",
"=",
"_jvm",
"(",
")",
".",
"org",
".",
"apache",
".",
"spark",
".",
"ml",
".",
"stat",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Summarizer.metrics | Given a list of metrics, provides a builder that it turns computes metrics from a column.
See the documentation of [[Summarizer]] for an example.
The following metrics are accepted (case sensitive):
- mean: a vector that contains the coefficient-wise mean.
- variance: a vector tha co... | python/pyspark/ml/stat.py | def metrics(*metrics):
"""
Given a list of metrics, provides a builder that it turns computes metrics from a column.
See the documentation of [[Summarizer]] for an example.
The following metrics are accepted (case sensitive):
- mean: a vector that contains the coefficient-wise... | def metrics(*metrics):
"""
Given a list of metrics, provides a builder that it turns computes metrics from a column.
See the documentation of [[Summarizer]] for an example.
The following metrics are accepted (case sensitive):
- mean: a vector that contains the coefficient-wise... | [
"Given",
"a",
"list",
"of",
"metrics",
"provides",
"a",
"builder",
"that",
"it",
"turns",
"computes",
"metrics",
"from",
"a",
"column",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/stat.py#L326-L353 | [
"def",
"metrics",
"(",
"*",
"metrics",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"js",
"=",
"JavaWrapper",
".",
"_new_java_obj",
"(",
"\"org.apache.spark.ml.stat.Summarizer.metrics\"",
",",
"_to_seq",
"(",
"sc",
",",
"metrics",
")",
")",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SummaryBuilder.summary | Returns an aggregate object that contains the summary of the column with the requested
metrics.
:param featuresCol:
a column that contains features Vector object.
:param weightCol:
a column that contains weight value. Default weight is 1.0.
:return:
an aggrega... | python/pyspark/ml/stat.py | def summary(self, featuresCol, weightCol=None):
"""
Returns an aggregate object that contains the summary of the column with the requested
metrics.
:param featuresCol:
a column that contains features Vector object.
:param weightCol:
a column that contains weigh... | def summary(self, featuresCol, weightCol=None):
"""
Returns an aggregate object that contains the summary of the column with the requested
metrics.
:param featuresCol:
a column that contains features Vector object.
:param weightCol:
a column that contains weigh... | [
"Returns",
"an",
"aggregate",
"object",
"that",
"contains",
"the",
"summary",
"of",
"the",
"column",
"with",
"the",
"requested",
"metrics",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/stat.py#L372-L386 | [
"def",
"summary",
"(",
"self",
",",
"featuresCol",
",",
"weightCol",
"=",
"None",
")",
":",
"featuresCol",
",",
"weightCol",
"=",
"Summarizer",
".",
"_check_param",
"(",
"featuresCol",
",",
"weightCol",
")",
"return",
"Column",
"(",
"self",
".",
"_java_obj",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Statistics.corr | Compute the correlation (matrix) for the input RDD(s) using the
specified method.
Methods currently supported: I{pearson (default), spearman}.
If a single RDD of Vectors is passed in, a correlation matrix
comparing the columns in the input RDD is returned. Use C{method=}
to spec... | python/pyspark/mllib/stat/_statistics.py | def corr(x, y=None, method=None):
"""
Compute the correlation (matrix) for the input RDD(s) using the
specified method.
Methods currently supported: I{pearson (default), spearman}.
If a single RDD of Vectors is passed in, a correlation matrix
comparing the columns in the... | def corr(x, y=None, method=None):
"""
Compute the correlation (matrix) for the input RDD(s) using the
specified method.
Methods currently supported: I{pearson (default), spearman}.
If a single RDD of Vectors is passed in, a correlation matrix
comparing the columns in the... | [
"Compute",
"the",
"correlation",
"(",
"matrix",
")",
"for",
"the",
"input",
"RDD",
"(",
"s",
")",
"using",
"the",
"specified",
"method",
".",
"Methods",
"currently",
"supported",
":",
"I",
"{",
"pearson",
"(",
"default",
")",
"spearman",
"}",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/stat/_statistics.py#L97-L157 | [
"def",
"corr",
"(",
"x",
",",
"y",
"=",
"None",
",",
"method",
"=",
"None",
")",
":",
"# Check inputs to determine whether a single value or a matrix is needed for output.",
"# Since it's legal for users to use the method name as the second argument, we need to",
"# check if y is use... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _parallelFitTasks | Creates a list of callables which can be called from different threads to fit and evaluate
an estimator in parallel. Each callable returns an `(index, metric)` pair.
:param est: Estimator, the estimator to be fit.
:param train: DataFrame, training data set, used for fitting.
:param eva: Evaluator, used... | python/pyspark/ml/tuning.py | def _parallelFitTasks(est, train, eva, validation, epm, collectSubModel):
"""
Creates a list of callables which can be called from different threads to fit and evaluate
an estimator in parallel. Each callable returns an `(index, metric)` pair.
:param est: Estimator, the estimator to be fit.
:param ... | def _parallelFitTasks(est, train, eva, validation, epm, collectSubModel):
"""
Creates a list of callables which can be called from different threads to fit and evaluate
an estimator in parallel. Each callable returns an `(index, metric)` pair.
:param est: Estimator, the estimator to be fit.
:param ... | [
"Creates",
"a",
"list",
"of",
"callables",
"which",
"can",
"be",
"called",
"from",
"different",
"threads",
"to",
"fit",
"and",
"evaluate",
"an",
"estimator",
"in",
"parallel",
".",
"Each",
"callable",
"returns",
"an",
"(",
"index",
"metric",
")",
"pair",
"... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L36-L56 | [
"def",
"_parallelFitTasks",
"(",
"est",
",",
"train",
",",
"eva",
",",
"validation",
",",
"epm",
",",
"collectSubModel",
")",
":",
"modelIter",
"=",
"est",
".",
"fitMultiple",
"(",
"train",
",",
"epm",
")",
"def",
"singleTask",
"(",
")",
":",
"index",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | ParamGridBuilder.baseOn | Sets the given parameters in this grid to fixed values.
Accepts either a parameter dictionary or a list of (parameter, value) pairs. | python/pyspark/ml/tuning.py | def baseOn(self, *args):
"""
Sets the given parameters in this grid to fixed values.
Accepts either a parameter dictionary or a list of (parameter, value) pairs.
"""
if isinstance(args[0], dict):
self.baseOn(*args[0].items())
else:
for (param, valu... | def baseOn(self, *args):
"""
Sets the given parameters in this grid to fixed values.
Accepts either a parameter dictionary or a list of (parameter, value) pairs.
"""
if isinstance(args[0], dict):
self.baseOn(*args[0].items())
else:
for (param, valu... | [
"Sets",
"the",
"given",
"parameters",
"in",
"this",
"grid",
"to",
"fixed",
"values",
".",
"Accepts",
"either",
"a",
"parameter",
"dictionary",
"or",
"a",
"list",
"of",
"(",
"parameter",
"value",
")",
"pairs",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L97-L108 | [
"def",
"baseOn",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"isinstance",
"(",
"args",
"[",
"0",
"]",
",",
"dict",
")",
":",
"self",
".",
"baseOn",
"(",
"*",
"args",
"[",
"0",
"]",
".",
"items",
"(",
")",
")",
"else",
":",
"for",
"(",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | ParamGridBuilder.build | Builds and returns all combinations of parameters specified
by the param grid. | python/pyspark/ml/tuning.py | def build(self):
"""
Builds and returns all combinations of parameters specified
by the param grid.
"""
keys = self._param_grid.keys()
grid_values = self._param_grid.values()
def to_key_value_pairs(keys, values):
return [(key, key.typeConverter(value)... | def build(self):
"""
Builds and returns all combinations of parameters specified
by the param grid.
"""
keys = self._param_grid.keys()
grid_values = self._param_grid.values()
def to_key_value_pairs(keys, values):
return [(key, key.typeConverter(value)... | [
"Builds",
"and",
"returns",
"all",
"combinations",
"of",
"parameters",
"specified",
"by",
"the",
"param",
"grid",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L111-L122 | [
"def",
"build",
"(",
"self",
")",
":",
"keys",
"=",
"self",
".",
"_param_grid",
".",
"keys",
"(",
")",
"grid_values",
"=",
"self",
".",
"_param_grid",
".",
"values",
"(",
")",
"def",
"to_key_value_pairs",
"(",
"keys",
",",
"values",
")",
":",
"return",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.