id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
19,100 | apache/spark | python/pyspark/streaming/dstream.py | DStream.transformWith | def transformWith(self, func, other, keepSerializer=False):
"""
Return a new DStream in which each RDD is generated by applying a function
on each RDD of this DStream and 'other' DStream.
`func` can have two arguments of (`rdd_a`, `rdd_b`) or have three
arguments of (`time`, `rd... | python | def transformWith(self, func, other, keepSerializer=False):
"""
Return a new DStream in which each RDD is generated by applying a function
on each RDD of this DStream and 'other' DStream.
`func` can have two arguments of (`rdd_a`, `rdd_b`) or have three
arguments of (`time`, `rd... | [
"def",
"transformWith",
"(",
"self",
",",
"func",
",",
"other",
",",
"keepSerializer",
"=",
"False",
")",
":",
"if",
"func",
".",
"__code__",
".",
"co_argcount",
"==",
"2",
":",
"oldfunc",
"=",
"func",
"func",
"=",
"lambda",
"t",
",",
"a",
",",
"b",
... | Return a new DStream in which each RDD is generated by applying a function
on each RDD of this DStream and 'other' DStream.
`func` can have two arguments of (`rdd_a`, `rdd_b`) or have three
arguments of (`time`, `rdd_a`, `rdd_b`) | [
"Return",
"a",
"new",
"DStream",
"in",
"which",
"each",
"RDD",
"is",
"generated",
"by",
"applying",
"a",
"function",
"on",
"each",
"RDD",
"of",
"this",
"DStream",
"and",
"other",
"DStream",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L301-L317 |
19,101 | apache/spark | python/pyspark/streaming/dstream.py | DStream.union | def union(self, other):
"""
Return a new DStream by unifying data of another DStream with this DStream.
@param other: Another DStream having the same interval (i.e., slideDuration)
as this DStream.
"""
if self._slideDuration != other._slideDuration:
... | python | def union(self, other):
"""
Return a new DStream by unifying data of another DStream with this DStream.
@param other: Another DStream having the same interval (i.e., slideDuration)
as this DStream.
"""
if self._slideDuration != other._slideDuration:
... | [
"def",
"union",
"(",
"self",
",",
"other",
")",
":",
"if",
"self",
".",
"_slideDuration",
"!=",
"other",
".",
"_slideDuration",
":",
"raise",
"ValueError",
"(",
"\"the two DStream should have same slide duration\"",
")",
"return",
"self",
".",
"transformWith",
"("... | Return a new DStream by unifying data of another DStream with this DStream.
@param other: Another DStream having the same interval (i.e., slideDuration)
as this DStream. | [
"Return",
"a",
"new",
"DStream",
"by",
"unifying",
"data",
"of",
"another",
"DStream",
"with",
"this",
"DStream",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L332-L341 |
19,102 | apache/spark | python/pyspark/streaming/dstream.py | DStream.cogroup | def cogroup(self, other, numPartitions=None):
"""
Return a new DStream by applying 'cogroup' between RDDs of this
DStream and `other` DStream.
Hash partitioning is used to generate the RDDs with `numPartitions` partitions.
"""
if numPartitions is None:
numPar... | python | def cogroup(self, other, numPartitions=None):
"""
Return a new DStream by applying 'cogroup' between RDDs of this
DStream and `other` DStream.
Hash partitioning is used to generate the RDDs with `numPartitions` partitions.
"""
if numPartitions is None:
numPar... | [
"def",
"cogroup",
"(",
"self",
",",
"other",
",",
"numPartitions",
"=",
"None",
")",
":",
"if",
"numPartitions",
"is",
"None",
":",
"numPartitions",
"=",
"self",
".",
"_sc",
".",
"defaultParallelism",
"return",
"self",
".",
"transformWith",
"(",
"lambda",
... | Return a new DStream by applying 'cogroup' between RDDs of this
DStream and `other` DStream.
Hash partitioning is used to generate the RDDs with `numPartitions` partitions. | [
"Return",
"a",
"new",
"DStream",
"by",
"applying",
"cogroup",
"between",
"RDDs",
"of",
"this",
"DStream",
"and",
"other",
"DStream",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L343-L352 |
19,103 | apache/spark | python/pyspark/streaming/dstream.py | DStream._jtime | def _jtime(self, timestamp):
""" Convert datetime or unix_timestamp into Time
"""
if isinstance(timestamp, datetime):
timestamp = time.mktime(timestamp.timetuple())
return self._sc._jvm.Time(long(timestamp * 1000)) | python | def _jtime(self, timestamp):
""" Convert datetime or unix_timestamp into Time
"""
if isinstance(timestamp, datetime):
timestamp = time.mktime(timestamp.timetuple())
return self._sc._jvm.Time(long(timestamp * 1000)) | [
"def",
"_jtime",
"(",
"self",
",",
"timestamp",
")",
":",
"if",
"isinstance",
"(",
"timestamp",
",",
"datetime",
")",
":",
"timestamp",
"=",
"time",
".",
"mktime",
"(",
"timestamp",
".",
"timetuple",
"(",
")",
")",
"return",
"self",
".",
"_sc",
".",
... | Convert datetime or unix_timestamp into Time | [
"Convert",
"datetime",
"or",
"unix_timestamp",
"into",
"Time"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L402-L407 |
19,104 | apache/spark | python/pyspark/streaming/dstream.py | DStream.window | def window(self, windowDuration, slideDuration=None):
"""
Return a new DStream in which each RDD contains all the elements in seen in a
sliding window of time over this DStream.
@param windowDuration: width of the window; must be a multiple of this DStream's
... | python | def window(self, windowDuration, slideDuration=None):
"""
Return a new DStream in which each RDD contains all the elements in seen in a
sliding window of time over this DStream.
@param windowDuration: width of the window; must be a multiple of this DStream's
... | [
"def",
"window",
"(",
"self",
",",
"windowDuration",
",",
"slideDuration",
"=",
"None",
")",
":",
"self",
".",
"_validate_window_param",
"(",
"windowDuration",
",",
"slideDuration",
")",
"d",
"=",
"self",
".",
"_ssc",
".",
"_jduration",
"(",
"windowDuration",
... | Return a new DStream in which each RDD contains all the elements in seen in a
sliding window of time over this DStream.
@param windowDuration: width of the window; must be a multiple of this DStream's
batching interval
@param slideDuration: sliding interval of the... | [
"Return",
"a",
"new",
"DStream",
"in",
"which",
"each",
"RDD",
"contains",
"all",
"the",
"elements",
"in",
"seen",
"in",
"a",
"sliding",
"window",
"of",
"time",
"over",
"this",
"DStream",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L427-L443 |
19,105 | apache/spark | python/pyspark/streaming/dstream.py | DStream.reduceByWindow | def reduceByWindow(self, reduceFunc, invReduceFunc, windowDuration, slideDuration):
"""
Return a new DStream in which each RDD has a single element generated by reducing all
elements in a sliding window over this DStream.
if `invReduceFunc` is not None, the reduction is done incremental... | python | def reduceByWindow(self, reduceFunc, invReduceFunc, windowDuration, slideDuration):
"""
Return a new DStream in which each RDD has a single element generated by reducing all
elements in a sliding window over this DStream.
if `invReduceFunc` is not None, the reduction is done incremental... | [
"def",
"reduceByWindow",
"(",
"self",
",",
"reduceFunc",
",",
"invReduceFunc",
",",
"windowDuration",
",",
"slideDuration",
")",
":",
"keyed",
"=",
"self",
".",
"map",
"(",
"lambda",
"x",
":",
"(",
"1",
",",
"x",
")",
")",
"reduced",
"=",
"keyed",
".",... | Return a new DStream in which each RDD has a single element generated by reducing all
elements in a sliding window over this DStream.
if `invReduceFunc` is not None, the reduction is done incrementally
using the old window's reduced value :
1. reduce the new values that entered the win... | [
"Return",
"a",
"new",
"DStream",
"in",
"which",
"each",
"RDD",
"has",
"a",
"single",
"element",
"generated",
"by",
"reducing",
"all",
"elements",
"in",
"a",
"sliding",
"window",
"over",
"this",
"DStream",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L445-L471 |
19,106 | apache/spark | python/pyspark/streaming/dstream.py | DStream.countByValueAndWindow | def countByValueAndWindow(self, windowDuration, slideDuration, numPartitions=None):
"""
Return a new DStream in which each RDD contains the count of distinct elements in
RDDs in a sliding window over this DStream.
@param windowDuration: width of the window; must be a multiple of this DS... | python | def countByValueAndWindow(self, windowDuration, slideDuration, numPartitions=None):
"""
Return a new DStream in which each RDD contains the count of distinct elements in
RDDs in a sliding window over this DStream.
@param windowDuration: width of the window; must be a multiple of this DS... | [
"def",
"countByValueAndWindow",
"(",
"self",
",",
"windowDuration",
",",
"slideDuration",
",",
"numPartitions",
"=",
"None",
")",
":",
"keyed",
"=",
"self",
".",
"map",
"(",
"lambda",
"x",
":",
"(",
"x",
",",
"1",
")",
")",
"counted",
"=",
"keyed",
"."... | Return a new DStream in which each RDD contains the count of distinct elements in
RDDs in a sliding window over this DStream.
@param windowDuration: width of the window; must be a multiple of this DStream's
batching interval
@param slideDuration: sliding interval ... | [
"Return",
"a",
"new",
"DStream",
"in",
"which",
"each",
"RDD",
"contains",
"the",
"count",
"of",
"distinct",
"elements",
"in",
"RDDs",
"in",
"a",
"sliding",
"window",
"over",
"this",
"DStream",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L485-L500 |
19,107 | apache/spark | python/pyspark/streaming/dstream.py | DStream.reduceByKeyAndWindow | def reduceByKeyAndWindow(self, func, invFunc, windowDuration, slideDuration=None,
numPartitions=None, filterFunc=None):
"""
Return a new DStream by applying incremental `reduceByKey` over a sliding window.
The reduced value of over a new window is calculated using t... | python | def reduceByKeyAndWindow(self, func, invFunc, windowDuration, slideDuration=None,
numPartitions=None, filterFunc=None):
"""
Return a new DStream by applying incremental `reduceByKey` over a sliding window.
The reduced value of over a new window is calculated using t... | [
"def",
"reduceByKeyAndWindow",
"(",
"self",
",",
"func",
",",
"invFunc",
",",
"windowDuration",
",",
"slideDuration",
"=",
"None",
",",
"numPartitions",
"=",
"None",
",",
"filterFunc",
"=",
"None",
")",
":",
"self",
".",
"_validate_window_param",
"(",
"windowD... | Return a new DStream by applying incremental `reduceByKey` over a sliding window.
The reduced value of over a new window is calculated using the old window's reduce value :
1. reduce the new values that entered the window (e.g., adding new counts)
2. "inverse reduce" the old values that left ... | [
"Return",
"a",
"new",
"DStream",
"by",
"applying",
"incremental",
"reduceByKey",
"over",
"a",
"sliding",
"window",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L519-L574 |
19,108 | apache/spark | python/pyspark/streaming/dstream.py | DStream.updateStateByKey | def updateStateByKey(self, updateFunc, numPartitions=None, initialRDD=None):
"""
Return a new "state" DStream where the state for each key is updated by applying
the given function on the previous state of the key and the new values of the key.
@param updateFunc: State update function. ... | python | def updateStateByKey(self, updateFunc, numPartitions=None, initialRDD=None):
"""
Return a new "state" DStream where the state for each key is updated by applying
the given function on the previous state of the key and the new values of the key.
@param updateFunc: State update function. ... | [
"def",
"updateStateByKey",
"(",
"self",
",",
"updateFunc",
",",
"numPartitions",
"=",
"None",
",",
"initialRDD",
"=",
"None",
")",
":",
"if",
"numPartitions",
"is",
"None",
":",
"numPartitions",
"=",
"self",
".",
"_sc",
".",
"defaultParallelism",
"if",
"init... | Return a new "state" DStream where the state for each key is updated by applying
the given function on the previous state of the key and the new values of the key.
@param updateFunc: State update function. If this function returns None, then
corresponding state key-value pair... | [
"Return",
"a",
"new",
"state",
"DStream",
"where",
"the",
"state",
"for",
"each",
"key",
"is",
"updated",
"by",
"applying",
"the",
"given",
"function",
"on",
"the",
"previous",
"state",
"of",
"the",
"key",
"and",
"the",
"new",
"values",
"of",
"the",
"key... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L576-L608 |
19,109 | apache/spark | python/pyspark/traceback_utils.py | first_spark_call | def first_spark_call():
"""
Return a CallSite representing the first Spark call in the current call stack.
"""
tb = traceback.extract_stack()
if len(tb) == 0:
return None
file, line, module, what = tb[len(tb) - 1]
sparkpath = os.path.dirname(file)
first_spark_frame = len(tb) - 1
... | python | def first_spark_call():
"""
Return a CallSite representing the first Spark call in the current call stack.
"""
tb = traceback.extract_stack()
if len(tb) == 0:
return None
file, line, module, what = tb[len(tb) - 1]
sparkpath = os.path.dirname(file)
first_spark_frame = len(tb) - 1
... | [
"def",
"first_spark_call",
"(",
")",
":",
"tb",
"=",
"traceback",
".",
"extract_stack",
"(",
")",
"if",
"len",
"(",
"tb",
")",
"==",
"0",
":",
"return",
"None",
"file",
",",
"line",
",",
"module",
",",
"what",
"=",
"tb",
"[",
"len",
"(",
"tb",
")... | Return a CallSite representing the first Spark call in the current call stack. | [
"Return",
"a",
"CallSite",
"representing",
"the",
"first",
"Spark",
"call",
"in",
"the",
"current",
"call",
"stack",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/traceback_utils.py#L26-L46 |
19,110 | apache/spark | examples/src/main/python/mllib/logistic_regression.py | parsePoint | 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:]) | python | 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",
")",
":",
"values",
"=",
"[",
"float",
"(",
"s",
")",
"for",
"s",
"in",
"line",
".",
"split",
"(",
"' '",
")",
"]",
"if",
"values",
"[",
"0",
"]",
"==",
"-",
"1",
":",
"# Convert -1 labels to 0 for MLlib",
"values",
... | Parse a line of text into an MLlib LabeledPoint object. | [
"Parse",
"a",
"line",
"of",
"text",
"into",
"an",
"MLlib",
"LabeledPoint",
"object",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/examples/src/main/python/mllib/logistic_regression.py#L32-L39 |
19,111 | apache/spark | python/pyspark/mllib/evaluation.py | MulticlassMetrics.fMeasure | 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) | python | 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",
")",
":",
"if",
"beta",
"is",
"None",
":",
"return",
"self",
".",
"call",
"(",
"\"fMeasure\"",
",",
"label",
")",
"else",
":",
"return",
"self",
".",
"call",
"(",
"\"fMeasure\"",... | Returns f-measure. | [
"Returns",
"f",
"-",
"measure",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/evaluation.py#L297-L304 |
19,112 | apache/spark | python/pyspark/sql/dataframe.py | _to_corrected_pandas_type | 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
... | python | 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",
")",
":",
"import",
"numpy",
"as",
"np",
"if",
"type",
"(",
"dt",
")",
"==",
"ByteType",
":",
"return",
"np",
".",
"int8",
"elif",
"type",
"(",
"dt",
")",
"==",
"ShortType",
":",
"return",
"np",
".",
"in... | 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. | [
"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... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L2239-L2254 |
19,113 | apache/spark | python/pyspark/sql/dataframe.py | DataFrame.show | 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... | python | 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",
")",
":",
"if",
"isinstance",
"(",
"truncate",
",",
"bool",
")",
"and",
"truncate",
":",
"print",
"(",
"self",
".",
"_jdf",
".",
"showStri... | 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... | [
"Prints",
"the",
"first",
"n",
"rows",
"to",
"the",
"console",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L324-L361 |
19,114 | apache/spark | python/pyspark/sql/dataframe.py | DataFrame._repr_html_ | 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... | python | 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",
")",
":",
"import",
"cgi",
"if",
"not",
"self",
".",
"_support_repr_html",
":",
"self",
".",
"_support_repr_html",
"=",
"True",
"if",
"self",
".",
"sql_ctx",
".",
"_conf",
".",
"isReplEagerEvalEnabled",
"(",
")",
":",
"ma... | 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. | [
"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... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L372-L403 |
19,115 | apache/spark | python/pyspark/sql/dataframe.py | DataFrame.localCheckpoint | 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... | python | 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",
")",
":",
"jdf",
"=",
"self",
".",
"_jdf",
".",
"localCheckpoint",
"(",
"eager",
")",
"return",
"DataFrame",
"(",
"jdf",
",",
"self",
".",
"sql_ctx",
")"
] | 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... | [
"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... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L420-L431 |
19,116 | apache/spark | python/pyspark/sql/dataframe.py | DataFrame.hint | 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... | python | 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",
")",
":",
"if",
"len",
"(",
"parameters",
")",
"==",
"1",
"and",
"isinstance",
"(",
"parameters",
"[",
"0",
"]",
",",
"list",
")",
":",
"parameters",
"=",
"parameters",
"[",
"0",
"]",... | 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... | [
"Specifies",
"some",
"hint",
"on",
"the",
"current",
"DataFrame",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L468-L496 |
19,117 | apache/spark | python/pyspark/sql/dataframe.py | DataFrame.limit | 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) | python | 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",
")",
":",
"jdf",
"=",
"self",
".",
"_jdf",
".",
"limit",
"(",
"num",
")",
"return",
"DataFrame",
"(",
"jdf",
",",
"self",
".",
"sql_ctx",
")"
] | Limits the result count to the number specified.
>>> df.limit(1).collect()
[Row(age=2, name=u'Alice')]
>>> df.limit(0).collect()
[] | [
"Limits",
"the",
"result",
"count",
"to",
"the",
"number",
"specified",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L535-L544 |
19,118 | apache/spark | python/pyspark/sql/dataframe.py | DataFrame.sampleBy | 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
... | python | 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",
")",
":",
"if",
"isinstance",
"(",
"col",
",",
"basestring",
")",
":",
"col",
"=",
"Column",
"(",
"col",
")",
"elif",
"not",
"isinstance",
"(",
"col",
",",
"Col... | 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... | [
"Returns",
"a",
"stratified",
"sample",
"without",
"replacement",
"based",
"on",
"the",
"fraction",
"given",
"on",
"each",
"stratum",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L849-L889 |
19,119 | apache/spark | python/pyspark/sql/dataframe.py | DataFrame.dtypes | 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] | python | 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",
")",
":",
"return",
"[",
"(",
"str",
"(",
"f",
".",
"name",
")",
",",
"f",
".",
"dataType",
".",
"simpleString",
"(",
")",
")",
"for",
"f",
"in",
"self",
".",
"schema",
".",
"fields",
"]"
] | Returns all column names and their data types as a list.
>>> df.dtypes
[('age', 'int'), ('name', 'string')] | [
"Returns",
"all",
"column",
"names",
"and",
"their",
"data",
"types",
"as",
"a",
"list",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L915-L921 |
19,120 | apache/spark | python/pyspark/sql/dataframe.py | DataFrame._jseq | 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) | python | 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",
"_to_seq",
"(",
"self",
".",
"sql_ctx",
".",
"_sc",
",",
"cols",
",",
"converter",
")"
] | Return a JVM Seq of Columns from a list of Column or names | [
"Return",
"a",
"JVM",
"Seq",
"of",
"Columns",
"from",
"a",
"list",
"of",
"Column",
"or",
"names"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1097-L1099 |
19,121 | apache/spark | python/pyspark/sql/dataframe.py | DataFrame._jcols | 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... | python | 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",
")",
":",
"if",
"len",
"(",
"cols",
")",
"==",
"1",
"and",
"isinstance",
"(",
"cols",
"[",
"0",
"]",
",",
"list",
")",
":",
"cols",
"=",
"cols",
"[",
"0",
"]",
"return",
"self",
".",
"_jseq",
"(... | 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. | [
"Return",
"a",
"JVM",
"Seq",
"of",
"Columns",
"from",
"a",
"list",
"of",
"Column",
"or",
"column",
"names"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1105-L1112 |
19,122 | apache/spark | python/pyspark/sql/dataframe.py | DataFrame._sort_cols | 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... | python | 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",
")",
":",
"if",
"not",
"cols",
":",
"raise",
"ValueError",
"(",
"\"should sort by at least one column\"",
")",
"if",
"len",
"(",
"cols",
")",
"==",
"1",
"and",
"isinstance",
"(",
"cols",
"[",
... | Return a JVM Seq of Columns that describes the sort order | [
"Return",
"a",
"JVM",
"Seq",
"of",
"Columns",
"that",
"describes",
"the",
"sort",
"order"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1114-L1131 |
19,123 | apache/spark | python/pyspark/sql/dataframe.py | DataFrame.describe | 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 ... | python | 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",
")",
":",
"if",
"len",
"(",
"cols",
")",
"==",
"1",
"and",
"isinstance",
"(",
"cols",
"[",
"0",
"]",
",",
"list",
")",
":",
"cols",
"=",
"cols",
"[",
"0",
"]",
"jdf",
"=",
"self",
".",
"_jdf",... | 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... | [
"Computes",
"basic",
"statistics",
"for",
"numeric",
"and",
"string",
"columns",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1134-L1169 |
19,124 | apache/spark | python/pyspark/sql/dataframe.py | DataFrame.head | 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... | python | 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",
")",
":",
"if",
"n",
"is",
"None",
":",
"rs",
"=",
"self",
".",
"head",
"(",
"1",
")",
"return",
"rs",
"[",
"0",
"]",
"if",
"rs",
"else",
"None",
"return",
"self",
".",
"take",
"(",
"n",
")... | 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:`... | [
"Returns",
"the",
"first",
"n",
"rows",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1230-L1248 |
19,125 | apache/spark | python/pyspark/sql/dataframe.py | DataFrame.filter | 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... | python | 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",
")",
":",
"if",
"isinstance",
"(",
"condition",
",",
"basestring",
")",
":",
"jdf",
"=",
"self",
".",
"_jdf",
".",
"filter",
"(",
"condition",
")",
"elif",
"isinstance",
"(",
"condition",
",",
"Column",
"... | 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 ... | [
"Filters",
"rows",
"using",
"the",
"given",
"condition",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1335-L1359 |
19,126 | apache/spark | python/pyspark/sql/dataframe.py | DataFrame.approxQuantile | 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
... | python | 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",
")",
":",
"if",
"not",
"isinstance",
"(",
"col",
",",
"(",
"basestring",
",",
"list",
",",
"tuple",
")",
")",
":",
"raise",
"ValueError",
"(",
"\"col should be a ... | 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... | [
"Calculates",
"the",
"approximate",
"quantiles",
"of",
"numerical",
"columns",
"of",
"a",
"DataFrame",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1808-L1879 |
19,127 | apache/spark | python/pyspark/sql/dataframe.py | DataFrame._collectAsArrow | 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... | python | 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",
")",
":",
"with",
"SCCallSiteSync",
"(",
"self",
".",
"_sc",
")",
"as",
"css",
":",
"sock_info",
"=",
"self",
".",
"_jdf",
".",
"collectAsArrowToPython",
"(",
")",
"# Collect list of un-ordered batches where last element is a l... | Returns all records as a list of ArrowRecordBatches, pyarrow must be installed
and available on driver and worker Python environments.
.. note:: Experimental. | [
"Returns",
"all",
"records",
"as",
"a",
"list",
"of",
"ArrowRecordBatches",
"pyarrow",
"must",
"be",
"installed",
"and",
"available",
"on",
"driver",
"and",
"worker",
"Python",
"environments",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L2194-L2210 |
19,128 | apache/spark | sql/gen-sql-markdown.py | _list_function_infos | 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... | python | 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",
")",
":",
"jinfos",
"=",
"jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",
"sql",
".",
"api",
".",
"python",
".",
"PythonSQLUtils",
".",
"listBuiltinFunctionInfos",
"(",
")",
"infos",
"=",
"[",
"]",
"for",
... | Returns a list of function information via JVM. Sorts wrapped expression infos by name
and returns them. | [
"Returns",
"a",
"list",
"of",
"function",
"information",
"via",
"JVM",
".",
"Sorts",
"wrapped",
"expression",
"infos",
"by",
"name",
"and",
"returns",
"them",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/sql/gen-sql-markdown.py#L26-L47 |
19,129 | apache/spark | sql/gen-sql-markdown.py | _make_pretty_usage | 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 "%... | python | 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",
")",
":",
"if",
"usage",
"is",
"not",
"None",
"and",
"usage",
".",
"strip",
"(",
")",
"!=",
"\"\"",
":",
"usage",
"=",
"\"\\n\"",
".",
"join",
"(",
"map",
"(",
"lambda",
"u",
":",
"u",
".",
"strip",
"(",
... | Makes the usage description pretty and returns a formatted string if `usage`
is not an empty string. Otherwise, returns None. | [
"Makes",
"the",
"usage",
"description",
"pretty",
"and",
"returns",
"a",
"formatted",
"string",
"if",
"usage",
"is",
"not",
"an",
"empty",
"string",
".",
"Otherwise",
"returns",
"None",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/sql/gen-sql-markdown.py#L50-L58 |
19,130 | apache/spark | sql/gen-sql-markdown.py | _make_pretty_arguments | 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 - ...
...... | python | 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",
")",
":",
"if",
"arguments",
".",
"startswith",
"(",
"\"\\n Arguments:\"",
")",
":",
"arguments",
"=",
"\"\\n\"",
".",
"join",
"(",
"map",
"(",
"lambda",
"u",
":",
"u",
"[",
"6",
":",
"]",
",",
"argum... | 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... | [
"Makes",
"the",
"arguments",
"description",
"pretty",
"and",
"returns",
"a",
"formatted",
"string",
"if",
"arguments",
"starts",
"with",
"the",
"argument",
"prefix",
".",
"Otherwise",
"returns",
"None",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/sql/gen-sql-markdown.py#L61-L86 |
19,131 | apache/spark | sql/gen-sql-markdown.py | _make_pretty_examples | 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... | python | 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",
")",
":",
"if",
"examples",
".",
"startswith",
"(",
"\"\\n Examples:\"",
")",
":",
"examples",
"=",
"\"\\n\"",
".",
"join",
"(",
"map",
"(",
"lambda",
"u",
":",
"u",
"[",
"6",
":",
"]",
",",
"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... | [
"Makes",
"the",
"examples",
"description",
"pretty",
"and",
"returns",
"a",
"formatted",
"string",
"if",
"examples",
"starts",
"with",
"the",
"example",
"prefix",
".",
"Otherwise",
"returns",
"None",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/sql/gen-sql-markdown.py#L89-L116 |
19,132 | apache/spark | sql/gen-sql-markdown.py | _make_pretty_note | 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:... | python | 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",
")",
":",
"if",
"note",
"!=",
"\"\"",
":",
"note",
"=",
"\"\\n\"",
".",
"join",
"(",
"map",
"(",
"lambda",
"n",
":",
"n",
"[",
"4",
":",
"]",
",",
"note",
".",
"split",
"(",
"\"\\n\"",
")",
")",
")",
"re... | 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:**
... | [
"Makes",
"the",
"note",
"description",
"pretty",
"and",
"returns",
"a",
"formatted",
"string",
"if",
"note",
"is",
"not",
"an",
"empty",
"string",
".",
"Otherwise",
"returns",
"None",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/sql/gen-sql-markdown.py#L119-L137 |
19,133 | apache/spark | sql/gen-sql-markdown.py | _make_pretty_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 != "":
... | python | 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",
")",
":",
"if",
"deprecated",
"!=",
"\"\"",
":",
"deprecated",
"=",
"\"\\n\"",
".",
"join",
"(",
"map",
"(",
"lambda",
"n",
":",
"n",
"[",
"4",
":",
"]",
",",
"deprecated",
".",
"split",
"(",
"\"\\n\... | 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:**
... | [
"Makes",
"the",
"deprecated",
"description",
"pretty",
"and",
"returns",
"a",
"formatted",
"string",
"if",
"deprecated",
"is",
"not",
"an",
"empty",
"string",
".",
"Otherwise",
"returns",
"None",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/sql/gen-sql-markdown.py#L140-L158 |
19,134 | apache/spark | sql/gen-sql-markdown.py | generate_sql_markdown | 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
**... | python | 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",
")",
":",
"with",
"open",
"(",
"path",
",",
"'w'",
")",
"as",
"mdfile",
":",
"for",
"info",
"in",
"_list_function_infos",
"(",
"jvm",
")",
":",
"name",
"=",
"info",
".",
"name",
"usage",
"=",
"... | 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... | [
"Generates",
"a",
"markdown",
"file",
"after",
"listing",
"the",
"function",
"information",
".",
"The",
"output",
"file",
"is",
"created",
"in",
"path",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/sql/gen-sql-markdown.py#L161-L218 |
19,135 | apache/spark | python/pyspark/mllib/classification.py | LogisticRegressionWithLBFGS.train | 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... | python | 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",
"="... | 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... | [
"Train",
"a",
"logistic",
"regression",
"model",
"on",
"the",
"given",
"data",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/classification.py#L332-L400 |
19,136 | apache/spark | python/pyspark/heapq3.py | heappush | def heappush(heap, item):
"""Push item onto heap, maintaining the heap invariant."""
heap.append(item)
_siftdown(heap, 0, len(heap)-1) | python | 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",
")",
":",
"heap",
".",
"append",
"(",
"item",
")",
"_siftdown",
"(",
"heap",
",",
"0",
",",
"len",
"(",
"heap",
")",
"-",
"1",
")"
] | Push item onto heap, maintaining the heap invariant. | [
"Push",
"item",
"onto",
"heap",
"maintaining",
"the",
"heap",
"invariant",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L411-L414 |
19,137 | apache/spark | python/pyspark/heapq3.py | heappop | 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 | python | 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",
")",
":",
"lastelt",
"=",
"heap",
".",
"pop",
"(",
")",
"# raises appropriate IndexError if heap is empty",
"if",
"heap",
":",
"returnitem",
"=",
"heap",
"[",
"0",
"]",
"heap",
"[",
"0",
"]",
"=",
"lastelt",
"_siftup",
"(",
... | Pop the smallest item off the heap, maintaining the heap invariant. | [
"Pop",
"the",
"smallest",
"item",
"off",
"the",
"heap",
"maintaining",
"the",
"heap",
"invariant",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L416-L424 |
19,138 | apache/spark | python/pyspark/heapq3.py | heapreplace | 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... | python | 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",
")",
":",
"returnitem",
"=",
"heap",
"[",
"0",
"]",
"# raises appropriate IndexError if heap is empty",
"heap",
"[",
"0",
"]",
"=",
"item",
"_siftup",
"(",
"heap",
",",
"0",
")",
"return",
"returnitem"
] | 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... | [
"Pop",
"and",
"return",
"the",
"current",
"smallest",
"value",
"and",
"add",
"the",
"new",
"item",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L426-L440 |
19,139 | apache/spark | python/pyspark/heapq3.py | heappushpop | 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 | python | 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",
")",
":",
"if",
"heap",
"and",
"heap",
"[",
"0",
"]",
"<",
"item",
":",
"item",
",",
"heap",
"[",
"0",
"]",
"=",
"heap",
"[",
"0",
"]",
",",
"item",
"_siftup",
"(",
"heap",
",",
"0",
")",
"retur... | Fast version of a heappush followed by a heappop. | [
"Fast",
"version",
"of",
"a",
"heappush",
"followed",
"by",
"a",
"heappop",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L442-L447 |
19,140 | apache/spark | python/pyspark/heapq3.py | _heappop_max | 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 | python | 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",
")",
":",
"lastelt",
"=",
"heap",
".",
"pop",
"(",
")",
"# raises appropriate IndexError if heap is empty",
"if",
"heap",
":",
"returnitem",
"=",
"heap",
"[",
"0",
"]",
"heap",
"[",
"0",
"]",
"=",
"lastelt",
"_siftup_max",... | Maxheap version of a heappop. | [
"Maxheap",
"version",
"of",
"a",
"heappop",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L460-L468 |
19,141 | apache/spark | python/pyspark/heapq3.py | _heapreplace_max | 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 | python | 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",
")",
":",
"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. | [
"Maxheap",
"version",
"of",
"a",
"heappop",
"followed",
"by",
"a",
"heappush",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L470-L475 |
19,142 | apache/spark | python/pyspark/heapq3.py | _siftdown_max | 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:
... | python | 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",
")",
":",
"newitem",
"=",
"heap",
"[",
"pos",
"]",
"# Follow the path to the root, moving parents down until finding a place",
"# newitem fits.",
"while",
"pos",
">",
"startpos",
":",
"parentpos",
"=",
... | Maxheap variant of _siftdown | [
"Maxheap",
"variant",
"of",
"_siftdown"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L559-L572 |
19,143 | apache/spark | python/pyspark/heapq3.py | _siftup_max | 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.
... | python | 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",
")",
":",
"endpos",
"=",
"len",
"(",
"heap",
")",
"startpos",
"=",
"pos",
"newitem",
"=",
"heap",
"[",
"pos",
"]",
"# Bubble up the larger child until hitting a leaf.",
"childpos",
"=",
"2",
"*",
"pos",
"+",
"... | Maxheap variant of _siftup | [
"Maxheap",
"variant",
"of",
"_siftup"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L574-L593 |
19,144 | apache/spark | python/pyspark/heapq3.py | merge | 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... | python | 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",
")",
":",
"h",
"=",
"[",
"]",
"h_append",
"=",
"h",
".",
"append",
"if",
"reverse",
":",
"_heapify",
"=",
"_heapify_max",
"_heappop",
"=",
"_heappop_max",
"_heapre... | 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,... | [
"Merge",
"multiple",
"sorted",
"inputs",
"into",
"a",
"single",
"sorted",
"output",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L595-L673 |
19,145 | apache/spark | python/pyspark/heapq3.py | nsmallest | 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... | python | 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",
")",
":",
"# Short-cut for n==1 is to use min()",
"if",
"n",
"==",
"1",
":",
"it",
"=",
"iter",
"(",
"iterable",
")",
"sentinel",
"=",
"object",
"(",
")",
"if",
"key",
"is",
"None"... | Find the n smallest elements in a dataset.
Equivalent to: sorted(iterable, key=key)[:n] | [
"Find",
"the",
"n",
"smallest",
"elements",
"in",
"a",
"dataset",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L742-L803 |
19,146 | apache/spark | python/pyspark/heapq3.py | nlargest | 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... | python | 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",
")",
":",
"# Short-cut for n==1 is to use max()",
"if",
"n",
"==",
"1",
":",
"it",
"=",
"iter",
"(",
"iterable",
")",
"sentinel",
"=",
"object",
"(",
")",
"if",
"key",
"is",
"None",... | Find the n largest elements in a dataset.
Equivalent to: sorted(iterable, key=key, reverse=True)[:n] | [
"Find",
"the",
"n",
"largest",
"elements",
"in",
"a",
"dataset",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/heapq3.py#L805-L864 |
19,147 | apache/spark | python/pyspark/ml/stat.py | Correlation.corr | 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... | python | 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\"",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"javaCorrObj",
"=",
"_jvm",
"(",
")",
".",
"org",
".",
"apache",
".",
"spark",
".",
"ml",
".",
"stat",
"... | 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... | [
"Compute",
"the",
"correlation",
"matrix",
"with",
"specified",
"method",
"using",
"dataset",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/stat.py#L95-L136 |
19,148 | apache/spark | python/pyspark/ml/stat.py | Summarizer.metrics | 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... | python | 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",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"js",
"=",
"JavaWrapper",
".",
"_new_java_obj",
"(",
"\"org.apache.spark.ml.stat.Summarizer.metrics\"",
",",
"_to_seq",
"(",
"sc",
",",
"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... | [
"Given",
"a",
"list",
"of",
"metrics",
"provides",
"a",
"builder",
"that",
"it",
"turns",
"computes",
"metrics",
"from",
"a",
"column",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/stat.py#L326-L353 |
19,149 | apache/spark | python/pyspark/ml/stat.py | SummaryBuilder.summary | 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... | python | 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",
")",
":",
"featuresCol",
",",
"weightCol",
"=",
"Summarizer",
".",
"_check_param",
"(",
"featuresCol",
",",
"weightCol",
")",
"return",
"Column",
"(",
"self",
".",
"_java_obj",... | 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... | [
"Returns",
"an",
"aggregate",
"object",
"that",
"contains",
"the",
"summary",
"of",
"the",
"column",
"with",
"the",
"requested",
"metrics",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/stat.py#L372-L386 |
19,150 | apache/spark | python/pyspark/ml/tuning.py | ParamGridBuilder.build | 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)... | python | 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",
")",
":",
"keys",
"=",
"self",
".",
"_param_grid",
".",
"keys",
"(",
")",
"grid_values",
"=",
"self",
".",
"_param_grid",
".",
"values",
"(",
")",
"def",
"to_key_value_pairs",
"(",
"keys",
",",
"values",
")",
":",
"return",... | Builds and returns all combinations of parameters specified
by the param grid. | [
"Builds",
"and",
"returns",
"all",
"combinations",
"of",
"parameters",
"specified",
"by",
"the",
"param",
"grid",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L111-L122 |
19,151 | apache/spark | python/pyspark/ml/tuning.py | ValidatorParams._from_java_impl | def _from_java_impl(cls, java_stage):
"""
Return Python estimator, estimatorParamMaps, and evaluator from a Java ValidatorParams.
"""
# Load information from java_stage to the instance.
estimator = JavaParams._from_java(java_stage.getEstimator())
evaluator = JavaParams._... | python | def _from_java_impl(cls, java_stage):
"""
Return Python estimator, estimatorParamMaps, and evaluator from a Java ValidatorParams.
"""
# Load information from java_stage to the instance.
estimator = JavaParams._from_java(java_stage.getEstimator())
evaluator = JavaParams._... | [
"def",
"_from_java_impl",
"(",
"cls",
",",
"java_stage",
")",
":",
"# Load information from java_stage to the instance.",
"estimator",
"=",
"JavaParams",
".",
"_from_java",
"(",
"java_stage",
".",
"getEstimator",
"(",
")",
")",
"evaluator",
"=",
"JavaParams",
".",
"... | Return Python estimator, estimatorParamMaps, and evaluator from a Java ValidatorParams. | [
"Return",
"Python",
"estimator",
"estimatorParamMaps",
"and",
"evaluator",
"from",
"a",
"Java",
"ValidatorParams",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L173-L183 |
19,152 | apache/spark | python/pyspark/ml/tuning.py | ValidatorParams._to_java_impl | def _to_java_impl(self):
"""
Return Java estimator, estimatorParamMaps, and evaluator from this Python instance.
"""
gateway = SparkContext._gateway
cls = SparkContext._jvm.org.apache.spark.ml.param.ParamMap
java_epms = gateway.new_array(cls, len(self.getEstimatorParamM... | python | def _to_java_impl(self):
"""
Return Java estimator, estimatorParamMaps, and evaluator from this Python instance.
"""
gateway = SparkContext._gateway
cls = SparkContext._jvm.org.apache.spark.ml.param.ParamMap
java_epms = gateway.new_array(cls, len(self.getEstimatorParamM... | [
"def",
"_to_java_impl",
"(",
"self",
")",
":",
"gateway",
"=",
"SparkContext",
".",
"_gateway",
"cls",
"=",
"SparkContext",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",
"ml",
".",
"param",
".",
"ParamMap",
"java_epms",
"=",
"gateway",
".",
... | Return Java estimator, estimatorParamMaps, and evaluator from this Python instance. | [
"Return",
"Java",
"estimator",
"estimatorParamMaps",
"and",
"evaluator",
"from",
"this",
"Python",
"instance",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L185-L199 |
19,153 | apache/spark | python/pyspark/ml/tuning.py | CrossValidator._from_java | def _from_java(cls, java_stage):
"""
Given a Java CrossValidator, create and return a Python wrapper of it.
Used for ML persistence.
"""
estimator, epms, evaluator = super(CrossValidator, cls)._from_java_impl(java_stage)
numFolds = java_stage.getNumFolds()
seed =... | python | def _from_java(cls, java_stage):
"""
Given a Java CrossValidator, create and return a Python wrapper of it.
Used for ML persistence.
"""
estimator, epms, evaluator = super(CrossValidator, cls)._from_java_impl(java_stage)
numFolds = java_stage.getNumFolds()
seed =... | [
"def",
"_from_java",
"(",
"cls",
",",
"java_stage",
")",
":",
"estimator",
",",
"epms",
",",
"evaluator",
"=",
"super",
"(",
"CrossValidator",
",",
"cls",
")",
".",
"_from_java_impl",
"(",
"java_stage",
")",
"numFolds",
"=",
"java_stage",
".",
"getNumFolds",... | Given a Java CrossValidator, create and return a Python wrapper of it.
Used for ML persistence. | [
"Given",
"a",
"Java",
"CrossValidator",
"create",
"and",
"return",
"a",
"Python",
"wrapper",
"of",
"it",
".",
"Used",
"for",
"ML",
"persistence",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L351-L367 |
19,154 | apache/spark | python/pyspark/ml/tuning.py | CrossValidator._to_java | def _to_java(self):
"""
Transfer this instance to a Java CrossValidator. Used for ML persistence.
:return: Java object equivalent to this instance.
"""
estimator, epms, evaluator = super(CrossValidator, self)._to_java_impl()
_java_obj = JavaParams._new_java_obj("org.ap... | python | def _to_java(self):
"""
Transfer this instance to a Java CrossValidator. Used for ML persistence.
:return: Java object equivalent to this instance.
"""
estimator, epms, evaluator = super(CrossValidator, self)._to_java_impl()
_java_obj = JavaParams._new_java_obj("org.ap... | [
"def",
"_to_java",
"(",
"self",
")",
":",
"estimator",
",",
"epms",
",",
"evaluator",
"=",
"super",
"(",
"CrossValidator",
",",
"self",
")",
".",
"_to_java_impl",
"(",
")",
"_java_obj",
"=",
"JavaParams",
".",
"_new_java_obj",
"(",
"\"org.apache.spark.ml.tunin... | Transfer this instance to a Java CrossValidator. Used for ML persistence.
:return: Java object equivalent to this instance. | [
"Transfer",
"this",
"instance",
"to",
"a",
"Java",
"CrossValidator",
".",
"Used",
"for",
"ML",
"persistence",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L369-L387 |
19,155 | apache/spark | python/pyspark/ml/tuning.py | CrossValidatorModel.copy | def copy(self, extra=None):
"""
Creates a copy of this instance with a randomly generated uid
and some extra params. This copies the underlying bestModel,
creates a deep copy of the embedded paramMap, and
copies the embedded and extra parameters over.
It does not copy the... | python | def copy(self, extra=None):
"""
Creates a copy of this instance with a randomly generated uid
and some extra params. This copies the underlying bestModel,
creates a deep copy of the embedded paramMap, and
copies the embedded and extra parameters over.
It does not copy the... | [
"def",
"copy",
"(",
"self",
",",
"extra",
"=",
"None",
")",
":",
"if",
"extra",
"is",
"None",
":",
"extra",
"=",
"dict",
"(",
")",
"bestModel",
"=",
"self",
".",
"bestModel",
".",
"copy",
"(",
"extra",
")",
"avgMetrics",
"=",
"self",
".",
"avgMetri... | Creates a copy of this instance with a randomly generated uid
and some extra params. This copies the underlying bestModel,
creates a deep copy of the embedded paramMap, and
copies the embedded and extra parameters over.
It does not copy the extra Params into the subModels.
:para... | [
"Creates",
"a",
"copy",
"of",
"this",
"instance",
"with",
"a",
"randomly",
"generated",
"uid",
"and",
"some",
"extra",
"params",
".",
"This",
"copies",
"the",
"underlying",
"bestModel",
"creates",
"a",
"deep",
"copy",
"of",
"the",
"embedded",
"paramMap",
"an... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L414-L430 |
19,156 | apache/spark | python/pyspark/ml/tuning.py | TrainValidationSplit.copy | def copy(self, extra=None):
"""
Creates a copy of this instance with a randomly generated uid
and some extra params. This copies creates a deep copy of
the embedded paramMap, and copies the embedded and extra parameters over.
:param extra: Extra parameters to copy to the new ins... | python | def copy(self, extra=None):
"""
Creates a copy of this instance with a randomly generated uid
and some extra params. This copies creates a deep copy of
the embedded paramMap, and copies the embedded and extra parameters over.
:param extra: Extra parameters to copy to the new ins... | [
"def",
"copy",
"(",
"self",
",",
"extra",
"=",
"None",
")",
":",
"if",
"extra",
"is",
"None",
":",
"extra",
"=",
"dict",
"(",
")",
"newTVS",
"=",
"Params",
".",
"copy",
"(",
"self",
",",
"extra",
")",
"if",
"self",
".",
"isSet",
"(",
"self",
".... | Creates a copy of this instance with a randomly generated uid
and some extra params. This copies creates a deep copy of
the embedded paramMap, and copies the embedded and extra parameters over.
:param extra: Extra parameters to copy to the new instance
:return: Copy of this instance | [
"Creates",
"a",
"copy",
"of",
"this",
"instance",
"with",
"a",
"randomly",
"generated",
"uid",
"and",
"some",
"extra",
"params",
".",
"This",
"copies",
"creates",
"a",
"deep",
"copy",
"of",
"the",
"embedded",
"paramMap",
"and",
"copies",
"the",
"embedded",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L598-L615 |
19,157 | apache/spark | python/pyspark/ml/tuning.py | TrainValidationSplit._from_java | def _from_java(cls, java_stage):
"""
Given a Java TrainValidationSplit, create and return a Python wrapper of it.
Used for ML persistence.
"""
estimator, epms, evaluator = super(TrainValidationSplit, cls)._from_java_impl(java_stage)
trainRatio = java_stage.getTrainRatio(... | python | def _from_java(cls, java_stage):
"""
Given a Java TrainValidationSplit, create and return a Python wrapper of it.
Used for ML persistence.
"""
estimator, epms, evaluator = super(TrainValidationSplit, cls)._from_java_impl(java_stage)
trainRatio = java_stage.getTrainRatio(... | [
"def",
"_from_java",
"(",
"cls",
",",
"java_stage",
")",
":",
"estimator",
",",
"epms",
",",
"evaluator",
"=",
"super",
"(",
"TrainValidationSplit",
",",
"cls",
")",
".",
"_from_java_impl",
"(",
"java_stage",
")",
"trainRatio",
"=",
"java_stage",
".",
"getTr... | Given a Java TrainValidationSplit, create and return a Python wrapper of it.
Used for ML persistence. | [
"Given",
"a",
"Java",
"TrainValidationSplit",
"create",
"and",
"return",
"a",
"Python",
"wrapper",
"of",
"it",
".",
"Used",
"for",
"ML",
"persistence",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L629-L645 |
19,158 | apache/spark | python/pyspark/ml/tuning.py | TrainValidationSplitModel.copy | def copy(self, extra=None):
"""
Creates a copy of this instance with a randomly generated uid
and some extra params. This copies the underlying bestModel,
creates a deep copy of the embedded paramMap, and
copies the embedded and extra parameters over.
And, this creates a ... | python | def copy(self, extra=None):
"""
Creates a copy of this instance with a randomly generated uid
and some extra params. This copies the underlying bestModel,
creates a deep copy of the embedded paramMap, and
copies the embedded and extra parameters over.
And, this creates a ... | [
"def",
"copy",
"(",
"self",
",",
"extra",
"=",
"None",
")",
":",
"if",
"extra",
"is",
"None",
":",
"extra",
"=",
"dict",
"(",
")",
"bestModel",
"=",
"self",
".",
"bestModel",
".",
"copy",
"(",
"extra",
")",
"validationMetrics",
"=",
"list",
"(",
"s... | Creates a copy of this instance with a randomly generated uid
and some extra params. This copies the underlying bestModel,
creates a deep copy of the embedded paramMap, and
copies the embedded and extra parameters over.
And, this creates a shallow copy of the validationMetrics.
I... | [
"Creates",
"a",
"copy",
"of",
"this",
"instance",
"with",
"a",
"randomly",
"generated",
"uid",
"and",
"some",
"extra",
"params",
".",
"This",
"copies",
"the",
"underlying",
"bestModel",
"creates",
"a",
"deep",
"copy",
"of",
"the",
"embedded",
"paramMap",
"an... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L689-L706 |
19,159 | apache/spark | python/pyspark/ml/tuning.py | TrainValidationSplitModel._from_java | def _from_java(cls, java_stage):
"""
Given a Java TrainValidationSplitModel, create and return a Python wrapper of it.
Used for ML persistence.
"""
# Load information from java_stage to the instance.
bestModel = JavaParams._from_java(java_stage.bestModel())
estim... | python | def _from_java(cls, java_stage):
"""
Given a Java TrainValidationSplitModel, create and return a Python wrapper of it.
Used for ML persistence.
"""
# Load information from java_stage to the instance.
bestModel = JavaParams._from_java(java_stage.bestModel())
estim... | [
"def",
"_from_java",
"(",
"cls",
",",
"java_stage",
")",
":",
"# Load information from java_stage to the instance.",
"bestModel",
"=",
"JavaParams",
".",
"_from_java",
"(",
"java_stage",
".",
"bestModel",
"(",
")",
")",
"estimator",
",",
"epms",
",",
"evaluator",
... | Given a Java TrainValidationSplitModel, create and return a Python wrapper of it.
Used for ML persistence. | [
"Given",
"a",
"Java",
"TrainValidationSplitModel",
"create",
"and",
"return",
"a",
"Python",
"wrapper",
"of",
"it",
".",
"Used",
"for",
"ML",
"persistence",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L720-L739 |
19,160 | apache/spark | python/pyspark/sql/conf.py | RuntimeConfig.get | def get(self, key, default=_NoValue):
"""Returns the value of Spark runtime configuration property for the given key,
assuming it is set.
"""
self._checkType(key, "key")
if default is _NoValue:
return self._jconf.get(key)
else:
if default is not No... | python | def get(self, key, default=_NoValue):
"""Returns the value of Spark runtime configuration property for the given key,
assuming it is set.
"""
self._checkType(key, "key")
if default is _NoValue:
return self._jconf.get(key)
else:
if default is not No... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"default",
"=",
"_NoValue",
")",
":",
"self",
".",
"_checkType",
"(",
"key",
",",
"\"key\"",
")",
"if",
"default",
"is",
"_NoValue",
":",
"return",
"self",
".",
"_jconf",
".",
"get",
"(",
"key",
")",
"els... | Returns the value of Spark runtime configuration property for the given key,
assuming it is set. | [
"Returns",
"the",
"value",
"of",
"Spark",
"runtime",
"configuration",
"property",
"for",
"the",
"given",
"key",
"assuming",
"it",
"is",
"set",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/conf.py#L45-L55 |
19,161 | apache/spark | python/pyspark/sql/conf.py | RuntimeConfig._checkType | def _checkType(self, obj, identifier):
"""Assert that an object is of type str."""
if not isinstance(obj, basestring):
raise TypeError("expected %s '%s' to be a string (was '%s')" %
(identifier, obj, type(obj).__name__)) | python | def _checkType(self, obj, identifier):
"""Assert that an object is of type str."""
if not isinstance(obj, basestring):
raise TypeError("expected %s '%s' to be a string (was '%s')" %
(identifier, obj, type(obj).__name__)) | [
"def",
"_checkType",
"(",
"self",
",",
"obj",
",",
"identifier",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"basestring",
")",
":",
"raise",
"TypeError",
"(",
"\"expected %s '%s' to be a string (was '%s')\"",
"%",
"(",
"identifier",
",",
"obj",
",",... | Assert that an object is of type str. | [
"Assert",
"that",
"an",
"object",
"is",
"of",
"type",
"str",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/conf.py#L63-L67 |
19,162 | apache/spark | python/pyspark/sql/functions.py | _create_function | def _create_function(name, doc=""):
"""Create a PySpark function by its name"""
def _(col):
sc = SparkContext._active_spark_context
jc = getattr(sc._jvm.functions, name)(col._jc if isinstance(col, Column) else col)
return Column(jc)
_.__name__ = name
_.__doc__ = doc
return _ | python | def _create_function(name, doc=""):
"""Create a PySpark function by its name"""
def _(col):
sc = SparkContext._active_spark_context
jc = getattr(sc._jvm.functions, name)(col._jc if isinstance(col, Column) else col)
return Column(jc)
_.__name__ = name
_.__doc__ = doc
return _ | [
"def",
"_create_function",
"(",
"name",
",",
"doc",
"=",
"\"\"",
")",
":",
"def",
"_",
"(",
"col",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"getattr",
"(",
"sc",
".",
"_jvm",
".",
"functions",
",",
"name",
")",
"(... | Create a PySpark function by its name | [
"Create",
"a",
"PySpark",
"function",
"by",
"its",
"name"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L47-L55 |
19,163 | apache/spark | python/pyspark/sql/functions.py | _wrap_deprecated_function | def _wrap_deprecated_function(func, message):
""" Wrap the deprecated function to print out deprecation warnings"""
def _(col):
warnings.warn(message, DeprecationWarning)
return func(col)
return functools.wraps(func)(_) | python | def _wrap_deprecated_function(func, message):
""" Wrap the deprecated function to print out deprecation warnings"""
def _(col):
warnings.warn(message, DeprecationWarning)
return func(col)
return functools.wraps(func)(_) | [
"def",
"_wrap_deprecated_function",
"(",
"func",
",",
"message",
")",
":",
"def",
"_",
"(",
"col",
")",
":",
"warnings",
".",
"warn",
"(",
"message",
",",
"DeprecationWarning",
")",
"return",
"func",
"(",
"col",
")",
"return",
"functools",
".",
"wraps",
... | Wrap the deprecated function to print out deprecation warnings | [
"Wrap",
"the",
"deprecated",
"function",
"to",
"print",
"out",
"deprecation",
"warnings"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L72-L77 |
19,164 | apache/spark | python/pyspark/sql/functions.py | _create_binary_mathfunction | def _create_binary_mathfunction(name, doc=""):
""" Create a binary mathfunction by name"""
def _(col1, col2):
sc = SparkContext._active_spark_context
# For legacy reasons, the arguments here can be implicitly converted into floats,
# if they are not columns or strings.
if isinsta... | python | def _create_binary_mathfunction(name, doc=""):
""" Create a binary mathfunction by name"""
def _(col1, col2):
sc = SparkContext._active_spark_context
# For legacy reasons, the arguments here can be implicitly converted into floats,
# if they are not columns or strings.
if isinsta... | [
"def",
"_create_binary_mathfunction",
"(",
"name",
",",
"doc",
"=",
"\"\"",
")",
":",
"def",
"_",
"(",
"col1",
",",
"col2",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"# For legacy reasons, the arguments here can be implicitly converted into floa... | Create a binary mathfunction by name | [
"Create",
"a",
"binary",
"mathfunction",
"by",
"name"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L80-L104 |
19,165 | apache/spark | python/pyspark/sql/functions.py | _create_window_function | def _create_window_function(name, doc=''):
""" Create a window function by name """
def _():
sc = SparkContext._active_spark_context
jc = getattr(sc._jvm.functions, name)()
return Column(jc)
_.__name__ = name
_.__doc__ = 'Window function: ' + doc
return _ | python | def _create_window_function(name, doc=''):
""" Create a window function by name """
def _():
sc = SparkContext._active_spark_context
jc = getattr(sc._jvm.functions, name)()
return Column(jc)
_.__name__ = name
_.__doc__ = 'Window function: ' + doc
return _ | [
"def",
"_create_window_function",
"(",
"name",
",",
"doc",
"=",
"''",
")",
":",
"def",
"_",
"(",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"getattr",
"(",
"sc",
".",
"_jvm",
".",
"functions",
",",
"name",
")",
"(",
... | Create a window function by name | [
"Create",
"a",
"window",
"function",
"by",
"name"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L107-L115 |
19,166 | apache/spark | python/pyspark/sql/functions.py | broadcast | def broadcast(df):
"""Marks a DataFrame as small enough for use in broadcast joins."""
sc = SparkContext._active_spark_context
return DataFrame(sc._jvm.functions.broadcast(df._jdf), df.sql_ctx) | python | def broadcast(df):
"""Marks a DataFrame as small enough for use in broadcast joins."""
sc = SparkContext._active_spark_context
return DataFrame(sc._jvm.functions.broadcast(df._jdf), df.sql_ctx) | [
"def",
"broadcast",
"(",
"df",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"DataFrame",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"broadcast",
"(",
"df",
".",
"_jdf",
")",
",",
"df",
".",
"sql_ctx",
")"
] | Marks a DataFrame as small enough for use in broadcast joins. | [
"Marks",
"a",
"DataFrame",
"as",
"small",
"enough",
"for",
"use",
"in",
"broadcast",
"joins",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L333-L337 |
19,167 | apache/spark | python/pyspark/sql/functions.py | nanvl | def nanvl(col1, col2):
"""Returns col1 if it is not NaN, or col2 if col1 is NaN.
Both inputs should be floating point columns (:class:`DoubleType` or :class:`FloatType`).
>>> df = spark.createDataFrame([(1.0, float('nan')), (float('nan'), 2.0)], ("a", "b"))
>>> df.select(nanvl("a", "b").alias("r1"), n... | python | def nanvl(col1, col2):
"""Returns col1 if it is not NaN, or col2 if col1 is NaN.
Both inputs should be floating point columns (:class:`DoubleType` or :class:`FloatType`).
>>> df = spark.createDataFrame([(1.0, float('nan')), (float('nan'), 2.0)], ("a", "b"))
>>> df.select(nanvl("a", "b").alias("r1"), n... | [
"def",
"nanvl",
"(",
"col1",
",",
"col2",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"nanvl",
"(",
"_to_java_column",
"(",
"col1",
")",
",",
"_to_java_column",
"(",
... | Returns col1 if it is not NaN, or col2 if col1 is NaN.
Both inputs should be floating point columns (:class:`DoubleType` or :class:`FloatType`).
>>> df = spark.createDataFrame([(1.0, float('nan')), (float('nan'), 2.0)], ("a", "b"))
>>> df.select(nanvl("a", "b").alias("r1"), nanvl(df.a, df.b).alias("r2")).... | [
"Returns",
"col1",
"if",
"it",
"is",
"not",
"NaN",
"or",
"col2",
"if",
"col1",
"is",
"NaN",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L565-L575 |
19,168 | apache/spark | python/pyspark/sql/functions.py | shiftLeft | def shiftLeft(col, numBits):
"""Shift the given value numBits left.
>>> spark.createDataFrame([(21,)], ['a']).select(shiftLeft('a', 1).alias('r')).collect()
[Row(r=42)]
"""
sc = SparkContext._active_spark_context
return Column(sc._jvm.functions.shiftLeft(_to_java_column(col), numBits)) | python | def shiftLeft(col, numBits):
"""Shift the given value numBits left.
>>> spark.createDataFrame([(21,)], ['a']).select(shiftLeft('a', 1).alias('r')).collect()
[Row(r=42)]
"""
sc = SparkContext._active_spark_context
return Column(sc._jvm.functions.shiftLeft(_to_java_column(col), numBits)) | [
"def",
"shiftLeft",
"(",
"col",
",",
"numBits",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"shiftLeft",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"numBits",
")",... | Shift the given value numBits left.
>>> spark.createDataFrame([(21,)], ['a']).select(shiftLeft('a', 1).alias('r')).collect()
[Row(r=42)] | [
"Shift",
"the",
"given",
"value",
"numBits",
"left",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L645-L652 |
19,169 | apache/spark | python/pyspark/sql/functions.py | expr | def expr(str):
"""Parses the expression string into the column that it represents
>>> df.select(expr("length(name)")).collect()
[Row(length(name)=5), Row(length(name)=3)]
"""
sc = SparkContext._active_spark_context
return Column(sc._jvm.functions.expr(str)) | python | def expr(str):
"""Parses the expression string into the column that it represents
>>> df.select(expr("length(name)")).collect()
[Row(length(name)=5), Row(length(name)=3)]
"""
sc = SparkContext._active_spark_context
return Column(sc._jvm.functions.expr(str)) | [
"def",
"expr",
"(",
"str",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"expr",
"(",
"str",
")",
")"
] | Parses the expression string into the column that it represents
>>> df.select(expr("length(name)")).collect()
[Row(length(name)=5), Row(length(name)=3)] | [
"Parses",
"the",
"expression",
"string",
"into",
"the",
"column",
"that",
"it",
"represents"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L694-L701 |
19,170 | apache/spark | python/pyspark/sql/functions.py | log | def log(arg1, arg2=None):
"""Returns the first argument-based logarithm of the second argument.
If there is only one argument, then this takes the natural logarithm of the argument.
>>> df.select(log(10.0, df.age).alias('ten')).rdd.map(lambda l: str(l.ten)[:7]).collect()
['0.30102', '0.69897']
>>... | python | def log(arg1, arg2=None):
"""Returns the first argument-based logarithm of the second argument.
If there is only one argument, then this takes the natural logarithm of the argument.
>>> df.select(log(10.0, df.age).alias('ten')).rdd.map(lambda l: str(l.ten)[:7]).collect()
['0.30102', '0.69897']
>>... | [
"def",
"log",
"(",
"arg1",
",",
"arg2",
"=",
"None",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"arg2",
"is",
"None",
":",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"log",
"(",
"_to_java_column",
"(",
"arg1",
... | Returns the first argument-based logarithm of the second argument.
If there is only one argument, then this takes the natural logarithm of the argument.
>>> df.select(log(10.0, df.age).alias('ten')).rdd.map(lambda l: str(l.ten)[:7]).collect()
['0.30102', '0.69897']
>>> df.select(log(df.age).alias('e'... | [
"Returns",
"the",
"first",
"argument",
"-",
"based",
"logarithm",
"of",
"the",
"second",
"argument",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L778-L794 |
19,171 | apache/spark | python/pyspark/sql/functions.py | conv | def conv(col, fromBase, toBase):
"""
Convert a number in a string column from one base to another.
>>> df = spark.createDataFrame([("010101",)], ['n'])
>>> df.select(conv(df.n, 2, 16).alias('hex')).collect()
[Row(hex=u'15')]
"""
sc = SparkContext._active_spark_context
return Column(sc._... | python | def conv(col, fromBase, toBase):
"""
Convert a number in a string column from one base to another.
>>> df = spark.createDataFrame([("010101",)], ['n'])
>>> df.select(conv(df.n, 2, 16).alias('hex')).collect()
[Row(hex=u'15')]
"""
sc = SparkContext._active_spark_context
return Column(sc._... | [
"def",
"conv",
"(",
"col",
",",
"fromBase",
",",
"toBase",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"conv",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"fromBa... | Convert a number in a string column from one base to another.
>>> df = spark.createDataFrame([("010101",)], ['n'])
>>> df.select(conv(df.n, 2, 16).alias('hex')).collect()
[Row(hex=u'15')] | [
"Convert",
"a",
"number",
"in",
"a",
"string",
"column",
"from",
"one",
"base",
"to",
"another",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L810-L819 |
19,172 | apache/spark | python/pyspark/sql/functions.py | date_add | def date_add(start, days):
"""
Returns the date that is `days` days after `start`
>>> df = spark.createDataFrame([('2015-04-08',)], ['dt'])
>>> df.select(date_add(df.dt, 1).alias('next_date')).collect()
[Row(next_date=datetime.date(2015, 4, 9))]
"""
sc = SparkContext._active_spark_context
... | python | def date_add(start, days):
"""
Returns the date that is `days` days after `start`
>>> df = spark.createDataFrame([('2015-04-08',)], ['dt'])
>>> df.select(date_add(df.dt, 1).alias('next_date')).collect()
[Row(next_date=datetime.date(2015, 4, 9))]
"""
sc = SparkContext._active_spark_context
... | [
"def",
"date_add",
"(",
"start",
",",
"days",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"date_add",
"(",
"_to_java_column",
"(",
"start",
")",
",",
"days",
")",
"... | Returns the date that is `days` days after `start`
>>> df = spark.createDataFrame([('2015-04-08',)], ['dt'])
>>> df.select(date_add(df.dt, 1).alias('next_date')).collect()
[Row(next_date=datetime.date(2015, 4, 9))] | [
"Returns",
"the",
"date",
"that",
"is",
"days",
"days",
"after",
"start"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1058-L1067 |
19,173 | apache/spark | python/pyspark/sql/functions.py | datediff | def datediff(end, start):
"""
Returns the number of days from `start` to `end`.
>>> df = spark.createDataFrame([('2015-04-08','2015-05-10')], ['d1', 'd2'])
>>> df.select(datediff(df.d2, df.d1).alias('diff')).collect()
[Row(diff=32)]
"""
sc = SparkContext._active_spark_context
return Col... | python | def datediff(end, start):
"""
Returns the number of days from `start` to `end`.
>>> df = spark.createDataFrame([('2015-04-08','2015-05-10')], ['d1', 'd2'])
>>> df.select(datediff(df.d2, df.d1).alias('diff')).collect()
[Row(diff=32)]
"""
sc = SparkContext._active_spark_context
return Col... | [
"def",
"datediff",
"(",
"end",
",",
"start",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"datediff",
"(",
"_to_java_column",
"(",
"end",
")",
",",
"_to_java_column",
... | Returns the number of days from `start` to `end`.
>>> df = spark.createDataFrame([('2015-04-08','2015-05-10')], ['d1', 'd2'])
>>> df.select(datediff(df.d2, df.d1).alias('diff')).collect()
[Row(diff=32)] | [
"Returns",
"the",
"number",
"of",
"days",
"from",
"start",
"to",
"end",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1084-L1093 |
19,174 | apache/spark | python/pyspark/sql/functions.py | add_months | def add_months(start, months):
"""
Returns the date that is `months` months after `start`
>>> df = spark.createDataFrame([('2015-04-08',)], ['dt'])
>>> df.select(add_months(df.dt, 1).alias('next_month')).collect()
[Row(next_month=datetime.date(2015, 5, 8))]
"""
sc = SparkContext._active_spa... | python | def add_months(start, months):
"""
Returns the date that is `months` months after `start`
>>> df = spark.createDataFrame([('2015-04-08',)], ['dt'])
>>> df.select(add_months(df.dt, 1).alias('next_month')).collect()
[Row(next_month=datetime.date(2015, 5, 8))]
"""
sc = SparkContext._active_spa... | [
"def",
"add_months",
"(",
"start",
",",
"months",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"add_months",
"(",
"_to_java_column",
"(",
"start",
")",
",",
"months",
... | Returns the date that is `months` months after `start`
>>> df = spark.createDataFrame([('2015-04-08',)], ['dt'])
>>> df.select(add_months(df.dt, 1).alias('next_month')).collect()
[Row(next_month=datetime.date(2015, 5, 8))] | [
"Returns",
"the",
"date",
"that",
"is",
"months",
"months",
"after",
"start"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1097-L1106 |
19,175 | apache/spark | python/pyspark/sql/functions.py | date_trunc | def date_trunc(format, timestamp):
"""
Returns timestamp truncated to the unit specified by the format.
:param format: 'year', 'yyyy', 'yy', 'month', 'mon', 'mm',
'day', 'dd', 'hour', 'minute', 'second', 'week', 'quarter'
>>> df = spark.createDataFrame([('1997-02-28 05:02:11',)], ['t'])
>>... | python | def date_trunc(format, timestamp):
"""
Returns timestamp truncated to the unit specified by the format.
:param format: 'year', 'yyyy', 'yy', 'month', 'mon', 'mm',
'day', 'dd', 'hour', 'minute', 'second', 'week', 'quarter'
>>> df = spark.createDataFrame([('1997-02-28 05:02:11',)], ['t'])
>>... | [
"def",
"date_trunc",
"(",
"format",
",",
"timestamp",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"date_trunc",
"(",
"format",
",",
"_to_java_column",
"(",
"timestamp",
... | Returns timestamp truncated to the unit specified by the format.
:param format: 'year', 'yyyy', 'yy', 'month', 'mon', 'mm',
'day', 'dd', 'hour', 'minute', 'second', 'week', 'quarter'
>>> df = spark.createDataFrame([('1997-02-28 05:02:11',)], ['t'])
>>> df.select(date_trunc('year', df.t).alias('yea... | [
"Returns",
"timestamp",
"truncated",
"to",
"the",
"unit",
"specified",
"by",
"the",
"format",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1197-L1211 |
19,176 | apache/spark | python/pyspark/sql/functions.py | next_day | def next_day(date, dayOfWeek):
"""
Returns the first date which is later than the value of the date column.
Day of the week parameter is case insensitive, and accepts:
"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun".
>>> df = spark.createDataFrame([('2015-07-27',)], ['d'])
>>> df.select(ne... | python | def next_day(date, dayOfWeek):
"""
Returns the first date which is later than the value of the date column.
Day of the week parameter is case insensitive, and accepts:
"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun".
>>> df = spark.createDataFrame([('2015-07-27',)], ['d'])
>>> df.select(ne... | [
"def",
"next_day",
"(",
"date",
",",
"dayOfWeek",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"next_day",
"(",
"_to_java_column",
"(",
"date",
")",
",",
"dayOfWeek",
... | Returns the first date which is later than the value of the date column.
Day of the week parameter is case insensitive, and accepts:
"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun".
>>> df = spark.createDataFrame([('2015-07-27',)], ['d'])
>>> df.select(next_day(df.d, 'Sun').alias('date')).collect(... | [
"Returns",
"the",
"first",
"date",
"which",
"is",
"later",
"than",
"the",
"value",
"of",
"the",
"date",
"column",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1215-L1227 |
19,177 | apache/spark | python/pyspark/sql/functions.py | last_day | def last_day(date):
"""
Returns the last day of the month which the given date belongs to.
>>> df = spark.createDataFrame([('1997-02-10',)], ['d'])
>>> df.select(last_day(df.d).alias('date')).collect()
[Row(date=datetime.date(1997, 2, 28))]
"""
sc = SparkContext._active_spark_context
re... | python | def last_day(date):
"""
Returns the last day of the month which the given date belongs to.
>>> df = spark.createDataFrame([('1997-02-10',)], ['d'])
>>> df.select(last_day(df.d).alias('date')).collect()
[Row(date=datetime.date(1997, 2, 28))]
"""
sc = SparkContext._active_spark_context
re... | [
"def",
"last_day",
"(",
"date",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"last_day",
"(",
"_to_java_column",
"(",
"date",
")",
")",
")"
] | Returns the last day of the month which the given date belongs to.
>>> df = spark.createDataFrame([('1997-02-10',)], ['d'])
>>> df.select(last_day(df.d).alias('date')).collect()
[Row(date=datetime.date(1997, 2, 28))] | [
"Returns",
"the",
"last",
"day",
"of",
"the",
"month",
"which",
"the",
"given",
"date",
"belongs",
"to",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1231-L1240 |
19,178 | apache/spark | python/pyspark/sql/functions.py | from_utc_timestamp | def from_utc_timestamp(timestamp, tz):
"""
This is a common function for databases supporting TIMESTAMP WITHOUT TIMEZONE. This function
takes a timestamp which is timezone-agnostic, and interprets it as a timestamp in UTC, and
renders that timestamp as a timestamp in the given time zone.
However, t... | python | def from_utc_timestamp(timestamp, tz):
"""
This is a common function for databases supporting TIMESTAMP WITHOUT TIMEZONE. This function
takes a timestamp which is timezone-agnostic, and interprets it as a timestamp in UTC, and
renders that timestamp as a timestamp in the given time zone.
However, t... | [
"def",
"from_utc_timestamp",
"(",
"timestamp",
",",
"tz",
")",
":",
"warnings",
".",
"warn",
"(",
"\"Deprecated in 3.0. See SPARK-25496\"",
",",
"DeprecationWarning",
")",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"isinstance",
"(",
"tz",
",",
... | This is a common function for databases supporting TIMESTAMP WITHOUT TIMEZONE. This function
takes a timestamp which is timezone-agnostic, and interprets it as a timestamp in UTC, and
renders that timestamp as a timestamp in the given time zone.
However, timestamp in Spark represents number of microseconds... | [
"This",
"is",
"a",
"common",
"function",
"for",
"databases",
"supporting",
"TIMESTAMP",
"WITHOUT",
"TIMEZONE",
".",
"This",
"function",
"takes",
"a",
"timestamp",
"which",
"is",
"timezone",
"-",
"agnostic",
"and",
"interprets",
"it",
"as",
"a",
"timestamp",
"i... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1283-L1316 |
19,179 | apache/spark | python/pyspark/sql/functions.py | hash | def hash(*cols):
"""Calculates the hash code of given columns, and returns the result as an int column.
>>> spark.createDataFrame([('ABC',)], ['a']).select(hash('a').alias('hash')).collect()
[Row(hash=-757602832)]
"""
sc = SparkContext._active_spark_context
jc = sc._jvm.functions.hash(_to_seq(s... | python | def hash(*cols):
"""Calculates the hash code of given columns, and returns the result as an int column.
>>> spark.createDataFrame([('ABC',)], ['a']).select(hash('a').alias('hash')).collect()
[Row(hash=-757602832)]
"""
sc = SparkContext._active_spark_context
jc = sc._jvm.functions.hash(_to_seq(s... | [
"def",
"hash",
"(",
"*",
"cols",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"hash",
"(",
"_to_seq",
"(",
"sc",
",",
"cols",
",",
"_to_java_column",
")",
")",
"return",
"Column... | Calculates the hash code of given columns, and returns the result as an int column.
>>> spark.createDataFrame([('ABC',)], ['a']).select(hash('a').alias('hash')).collect()
[Row(hash=-757602832)] | [
"Calculates",
"the",
"hash",
"code",
"of",
"given",
"columns",
"and",
"returns",
"the",
"result",
"as",
"an",
"int",
"column",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1466-L1474 |
19,180 | apache/spark | python/pyspark/sql/functions.py | concat_ws | def concat_ws(sep, *cols):
"""
Concatenates multiple input string columns together into a single string column,
using the given separator.
>>> df = spark.createDataFrame([('abcd','123')], ['s', 'd'])
>>> df.select(concat_ws('-', df.s, df.d).alias('s')).collect()
[Row(s=u'abcd-123')]
"""
... | python | def concat_ws(sep, *cols):
"""
Concatenates multiple input string columns together into a single string column,
using the given separator.
>>> df = spark.createDataFrame([('abcd','123')], ['s', 'd'])
>>> df.select(concat_ws('-', df.s, df.d).alias('s')).collect()
[Row(s=u'abcd-123')]
"""
... | [
"def",
"concat_ws",
"(",
"sep",
",",
"*",
"cols",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"concat_ws",
"(",
"sep",
",",
"_to_seq",
"(",
"sc",
",",
"cols",
","... | Concatenates multiple input string columns together into a single string column,
using the given separator.
>>> df = spark.createDataFrame([('abcd','123')], ['s', 'd'])
>>> df.select(concat_ws('-', df.s, df.d).alias('s')).collect()
[Row(s=u'abcd-123')] | [
"Concatenates",
"multiple",
"input",
"string",
"columns",
"together",
"into",
"a",
"single",
"string",
"column",
"using",
"the",
"given",
"separator",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1511-L1521 |
19,181 | apache/spark | python/pyspark/sql/functions.py | format_string | def format_string(format, *cols):
"""
Formats the arguments in printf-style and returns the result as a string column.
:param col: the column name of the numeric value to be formatted
:param d: the N decimal places
>>> df = spark.createDataFrame([(5, "hello")], ['a', 'b'])
>>> df.select(format... | python | def format_string(format, *cols):
"""
Formats the arguments in printf-style and returns the result as a string column.
:param col: the column name of the numeric value to be formatted
:param d: the N decimal places
>>> df = spark.createDataFrame([(5, "hello")], ['a', 'b'])
>>> df.select(format... | [
"def",
"format_string",
"(",
"format",
",",
"*",
"cols",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"format_string",
"(",
"format",
",",
"_to_seq",
"(",
"sc",
",",
... | Formats the arguments in printf-style and returns the result as a string column.
:param col: the column name of the numeric value to be formatted
:param d: the N decimal places
>>> df = spark.createDataFrame([(5, "hello")], ['a', 'b'])
>>> df.select(format_string('%d %s', df.a, df.b).alias('v')).colle... | [
"Formats",
"the",
"arguments",
"in",
"printf",
"-",
"style",
"and",
"returns",
"the",
"result",
"as",
"a",
"string",
"column",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1563-L1575 |
19,182 | apache/spark | python/pyspark/sql/functions.py | instr | def instr(str, substr):
"""
Locate the position of the first occurrence of substr column in the given string.
Returns null if either of the arguments are null.
.. note:: The position is not zero based, but 1 based index. Returns 0 if substr
could not be found in str.
>>> df = spark.createD... | python | def instr(str, substr):
"""
Locate the position of the first occurrence of substr column in the given string.
Returns null if either of the arguments are null.
.. note:: The position is not zero based, but 1 based index. Returns 0 if substr
could not be found in str.
>>> df = spark.createD... | [
"def",
"instr",
"(",
"str",
",",
"substr",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"instr",
"(",
"_to_java_column",
"(",
"str",
")",
",",
"substr",
")",
")"
] | Locate the position of the first occurrence of substr column in the given string.
Returns null if either of the arguments are null.
.. note:: The position is not zero based, but 1 based index. Returns 0 if substr
could not be found in str.
>>> df = spark.createDataFrame([('abcd',)], ['s',])
>>... | [
"Locate",
"the",
"position",
"of",
"the",
"first",
"occurrence",
"of",
"substr",
"column",
"in",
"the",
"given",
"string",
".",
"Returns",
"null",
"if",
"either",
"of",
"the",
"arguments",
"are",
"null",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1579-L1592 |
19,183 | apache/spark | python/pyspark/sql/functions.py | substring | def substring(str, pos, len):
"""
Substring starts at `pos` and is of length `len` when str is String type or
returns the slice of byte array that starts at `pos` in byte and is of length `len`
when str is Binary type.
.. note:: The position is not zero based, but 1 based index.
>>> df = spark... | python | def substring(str, pos, len):
"""
Substring starts at `pos` and is of length `len` when str is String type or
returns the slice of byte array that starts at `pos` in byte and is of length `len`
when str is Binary type.
.. note:: The position is not zero based, but 1 based index.
>>> df = spark... | [
"def",
"substring",
"(",
"str",
",",
"pos",
",",
"len",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"substring",
"(",
"_to_java_column",
"(",
"str",
")",
",",
"pos"... | Substring starts at `pos` and is of length `len` when str is String type or
returns the slice of byte array that starts at `pos` in byte and is of length `len`
when str is Binary type.
.. note:: The position is not zero based, but 1 based index.
>>> df = spark.createDataFrame([('abcd',)], ['s',])
... | [
"Substring",
"starts",
"at",
"pos",
"and",
"is",
"of",
"length",
"len",
"when",
"str",
"is",
"String",
"type",
"or",
"returns",
"the",
"slice",
"of",
"byte",
"array",
"that",
"starts",
"at",
"pos",
"in",
"byte",
"and",
"is",
"of",
"length",
"len",
"whe... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1597-L1610 |
19,184 | apache/spark | python/pyspark/sql/functions.py | levenshtein | def levenshtein(left, right):
"""Computes the Levenshtein distance of the two given strings.
>>> df0 = spark.createDataFrame([('kitten', 'sitting',)], ['l', 'r'])
>>> df0.select(levenshtein('l', 'r').alias('d')).collect()
[Row(d=3)]
"""
sc = SparkContext._active_spark_context
jc = sc._jvm.f... | python | def levenshtein(left, right):
"""Computes the Levenshtein distance of the two given strings.
>>> df0 = spark.createDataFrame([('kitten', 'sitting',)], ['l', 'r'])
>>> df0.select(levenshtein('l', 'r').alias('d')).collect()
[Row(d=3)]
"""
sc = SparkContext._active_spark_context
jc = sc._jvm.f... | [
"def",
"levenshtein",
"(",
"left",
",",
"right",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"levenshtein",
"(",
"_to_java_column",
"(",
"left",
")",
",",
"_to_java_column",
"(",
"... | Computes the Levenshtein distance of the two given strings.
>>> df0 = spark.createDataFrame([('kitten', 'sitting',)], ['l', 'r'])
>>> df0.select(levenshtein('l', 'r').alias('d')).collect()
[Row(d=3)] | [
"Computes",
"the",
"Levenshtein",
"distance",
"of",
"the",
"two",
"given",
"strings",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1634-L1643 |
19,185 | apache/spark | python/pyspark/sql/functions.py | locate | def locate(substr, str, pos=1):
"""
Locate the position of the first occurrence of substr in a string column, after position pos.
.. note:: The position is not zero based, but 1 based index. Returns 0 if substr
could not be found in str.
:param substr: a string
:param str: a Column of :cla... | python | def locate(substr, str, pos=1):
"""
Locate the position of the first occurrence of substr in a string column, after position pos.
.. note:: The position is not zero based, but 1 based index. Returns 0 if substr
could not be found in str.
:param substr: a string
:param str: a Column of :cla... | [
"def",
"locate",
"(",
"substr",
",",
"str",
",",
"pos",
"=",
"1",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"locate",
"(",
"substr",
",",
"_to_java_column",
"(",
... | Locate the position of the first occurrence of substr in a string column, after position pos.
.. note:: The position is not zero based, but 1 based index. Returns 0 if substr
could not be found in str.
:param substr: a string
:param str: a Column of :class:`pyspark.sql.types.StringType`
:param... | [
"Locate",
"the",
"position",
"of",
"the",
"first",
"occurrence",
"of",
"substr",
"in",
"a",
"string",
"column",
"after",
"position",
"pos",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1647-L1663 |
19,186 | apache/spark | python/pyspark/sql/functions.py | lpad | def lpad(col, len, pad):
"""
Left-pad the string column to width `len` with `pad`.
>>> df = spark.createDataFrame([('abcd',)], ['s',])
>>> df.select(lpad(df.s, 6, '#').alias('s')).collect()
[Row(s=u'##abcd')]
"""
sc = SparkContext._active_spark_context
return Column(sc._jvm.functions.lp... | python | def lpad(col, len, pad):
"""
Left-pad the string column to width `len` with `pad`.
>>> df = spark.createDataFrame([('abcd',)], ['s',])
>>> df.select(lpad(df.s, 6, '#').alias('s')).collect()
[Row(s=u'##abcd')]
"""
sc = SparkContext._active_spark_context
return Column(sc._jvm.functions.lp... | [
"def",
"lpad",
"(",
"col",
",",
"len",
",",
"pad",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"lpad",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"len",
",",
... | Left-pad the string column to width `len` with `pad`.
>>> df = spark.createDataFrame([('abcd',)], ['s',])
>>> df.select(lpad(df.s, 6, '#').alias('s')).collect()
[Row(s=u'##abcd')] | [
"Left",
"-",
"pad",
"the",
"string",
"column",
"to",
"width",
"len",
"with",
"pad",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1668-L1677 |
19,187 | apache/spark | python/pyspark/sql/functions.py | repeat | def repeat(col, n):
"""
Repeats a string column n times, and returns it as a new string column.
>>> df = spark.createDataFrame([('ab',)], ['s',])
>>> df.select(repeat(df.s, 3).alias('s')).collect()
[Row(s=u'ababab')]
"""
sc = SparkContext._active_spark_context
return Column(sc._jvm.func... | python | def repeat(col, n):
"""
Repeats a string column n times, and returns it as a new string column.
>>> df = spark.createDataFrame([('ab',)], ['s',])
>>> df.select(repeat(df.s, 3).alias('s')).collect()
[Row(s=u'ababab')]
"""
sc = SparkContext._active_spark_context
return Column(sc._jvm.func... | [
"def",
"repeat",
"(",
"col",
",",
"n",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"repeat",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"n",
")",
")"
] | Repeats a string column n times, and returns it as a new string column.
>>> df = spark.createDataFrame([('ab',)], ['s',])
>>> df.select(repeat(df.s, 3).alias('s')).collect()
[Row(s=u'ababab')] | [
"Repeats",
"a",
"string",
"column",
"n",
"times",
"and",
"returns",
"it",
"as",
"a",
"new",
"string",
"column",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1696-L1705 |
19,188 | apache/spark | python/pyspark/sql/functions.py | split | def split(str, pattern, limit=-1):
"""
Splits str around matches of the given pattern.
:param str: a string expression to split
:param pattern: a string representing a regular expression. The regex string should be
a Java regular expression.
:param limit: an integer which controls the numbe... | python | def split(str, pattern, limit=-1):
"""
Splits str around matches of the given pattern.
:param str: a string expression to split
:param pattern: a string representing a regular expression. The regex string should be
a Java regular expression.
:param limit: an integer which controls the numbe... | [
"def",
"split",
"(",
"str",
",",
"pattern",
",",
"limit",
"=",
"-",
"1",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"split",
"(",
"_to_java_column",
"(",
"str",
... | Splits str around matches of the given pattern.
:param str: a string expression to split
:param pattern: a string representing a regular expression. The regex string should be
a Java regular expression.
:param limit: an integer which controls the number of times `pattern` is applied.
* ``l... | [
"Splits",
"str",
"around",
"matches",
"of",
"the",
"given",
"pattern",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1710-L1735 |
19,189 | apache/spark | python/pyspark/sql/functions.py | regexp_extract | def regexp_extract(str, pattern, idx):
r"""Extract a specific group matched by a Java regex, from the specified string column.
If the regex did not match, or the specified group did not match, an empty string is returned.
>>> df = spark.createDataFrame([('100-200',)], ['str'])
>>> df.select(regexp_extr... | python | def regexp_extract(str, pattern, idx):
r"""Extract a specific group matched by a Java regex, from the specified string column.
If the regex did not match, or the specified group did not match, an empty string is returned.
>>> df = spark.createDataFrame([('100-200',)], ['str'])
>>> df.select(regexp_extr... | [
"def",
"regexp_extract",
"(",
"str",
",",
"pattern",
",",
"idx",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"regexp_extract",
"(",
"_to_java_column",
"(",
"str",
")",
",",
"patter... | r"""Extract a specific group matched by a Java regex, from the specified string column.
If the regex did not match, or the specified group did not match, an empty string is returned.
>>> df = spark.createDataFrame([('100-200',)], ['str'])
>>> df.select(regexp_extract('str', r'(\d+)-(\d+)', 1).alias('d')).c... | [
"r",
"Extract",
"a",
"specific",
"group",
"matched",
"by",
"a",
"Java",
"regex",
"from",
"the",
"specified",
"string",
"column",
".",
"If",
"the",
"regex",
"did",
"not",
"match",
"or",
"the",
"specified",
"group",
"did",
"not",
"match",
"an",
"empty",
"s... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1740-L1756 |
19,190 | apache/spark | python/pyspark/sql/functions.py | regexp_replace | def regexp_replace(str, pattern, replacement):
r"""Replace all substrings of the specified string value that match regexp with rep.
>>> df = spark.createDataFrame([('100-200',)], ['str'])
>>> df.select(regexp_replace('str', r'(\d+)', '--').alias('d')).collect()
[Row(d=u'-----')]
"""
sc = SparkC... | python | def regexp_replace(str, pattern, replacement):
r"""Replace all substrings of the specified string value that match regexp with rep.
>>> df = spark.createDataFrame([('100-200',)], ['str'])
>>> df.select(regexp_replace('str', r'(\d+)', '--').alias('d')).collect()
[Row(d=u'-----')]
"""
sc = SparkC... | [
"def",
"regexp_replace",
"(",
"str",
",",
"pattern",
",",
"replacement",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"regexp_replace",
"(",
"_to_java_column",
"(",
"str",
")",
",",
... | r"""Replace all substrings of the specified string value that match regexp with rep.
>>> df = spark.createDataFrame([('100-200',)], ['str'])
>>> df.select(regexp_replace('str', r'(\d+)', '--').alias('d')).collect()
[Row(d=u'-----')] | [
"r",
"Replace",
"all",
"substrings",
"of",
"the",
"specified",
"string",
"value",
"that",
"match",
"regexp",
"with",
"rep",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1761-L1770 |
19,191 | apache/spark | python/pyspark/sql/functions.py | translate | def translate(srcCol, matching, replace):
"""A function translate any character in the `srcCol` by a character in `matching`.
The characters in `replace` is corresponding to the characters in `matching`.
The translate will happen when any character in the string matching with the character
in the `match... | python | def translate(srcCol, matching, replace):
"""A function translate any character in the `srcCol` by a character in `matching`.
The characters in `replace` is corresponding to the characters in `matching`.
The translate will happen when any character in the string matching with the character
in the `match... | [
"def",
"translate",
"(",
"srcCol",
",",
"matching",
",",
"replace",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"translate",
"(",
"_to_java_column",
"(",
"srcCol",
")",... | A function translate any character in the `srcCol` by a character in `matching`.
The characters in `replace` is corresponding to the characters in `matching`.
The translate will happen when any character in the string matching with the character
in the `matching`.
>>> spark.createDataFrame([('translate... | [
"A",
"function",
"translate",
"any",
"character",
"in",
"the",
"srcCol",
"by",
"a",
"character",
"in",
"matching",
".",
"The",
"characters",
"in",
"replace",
"is",
"corresponding",
"to",
"the",
"characters",
"in",
"matching",
".",
"The",
"translate",
"will",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1856-L1867 |
19,192 | apache/spark | python/pyspark/sql/functions.py | array_join | def array_join(col, delimiter, null_replacement=None):
"""
Concatenates the elements of `column` using the `delimiter`. Null values are replaced with
`null_replacement` if set, otherwise they are ignored.
>>> df = spark.createDataFrame([(["a", "b", "c"],), (["a", None],)], ['data'])
>>> df.select(a... | python | def array_join(col, delimiter, null_replacement=None):
"""
Concatenates the elements of `column` using the `delimiter`. Null values are replaced with
`null_replacement` if set, otherwise they are ignored.
>>> df = spark.createDataFrame([(["a", "b", "c"],), (["a", None],)], ['data'])
>>> df.select(a... | [
"def",
"array_join",
"(",
"col",
",",
"delimiter",
",",
"null_replacement",
"=",
"None",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"null_replacement",
"is",
"None",
":",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functio... | Concatenates the elements of `column` using the `delimiter`. Null values are replaced with
`null_replacement` if set, otherwise they are ignored.
>>> df = spark.createDataFrame([(["a", "b", "c"],), (["a", None],)], ['data'])
>>> df.select(array_join(df.data, ",").alias("joined")).collect()
[Row(joined=... | [
"Concatenates",
"the",
"elements",
"of",
"column",
"using",
"the",
"delimiter",
".",
"Null",
"values",
"are",
"replaced",
"with",
"null_replacement",
"if",
"set",
"otherwise",
"they",
"are",
"ignored",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1977-L1993 |
19,193 | apache/spark | python/pyspark/sql/functions.py | concat | def concat(*cols):
"""
Concatenates multiple input columns together into a single column.
The function works with strings, binary and compatible array columns.
>>> df = spark.createDataFrame([('abcd','123')], ['s', 'd'])
>>> df.select(concat(df.s, df.d).alias('s')).collect()
[Row(s=u'abcd123')]... | python | def concat(*cols):
"""
Concatenates multiple input columns together into a single column.
The function works with strings, binary and compatible array columns.
>>> df = spark.createDataFrame([('abcd','123')], ['s', 'd'])
>>> df.select(concat(df.s, df.d).alias('s')).collect()
[Row(s=u'abcd123')]... | [
"def",
"concat",
"(",
"*",
"cols",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"concat",
"(",
"_to_seq",
"(",
"sc",
",",
"cols",
",",
"_to_java_column",
")",
")",
... | Concatenates multiple input columns together into a single column.
The function works with strings, binary and compatible array columns.
>>> df = spark.createDataFrame([('abcd','123')], ['s', 'd'])
>>> df.select(concat(df.s, df.d).alias('s')).collect()
[Row(s=u'abcd123')]
>>> df = spark.createData... | [
"Concatenates",
"multiple",
"input",
"columns",
"together",
"into",
"a",
"single",
"column",
".",
"The",
"function",
"works",
"with",
"strings",
"binary",
"and",
"compatible",
"array",
"columns",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1998-L2012 |
19,194 | apache/spark | python/pyspark/sql/functions.py | explode | def explode(col):
"""
Returns a new row for each element in the given array or map.
Uses the default column name `col` for elements in the array and
`key` and `value` for elements in the map unless specified otherwise.
>>> from pyspark.sql import Row
>>> eDF = spark.createDataFrame([Row(a=1, in... | python | def explode(col):
"""
Returns a new row for each element in the given array or map.
Uses the default column name `col` for elements in the array and
`key` and `value` for elements in the map unless specified otherwise.
>>> from pyspark.sql import Row
>>> eDF = spark.createDataFrame([Row(a=1, in... | [
"def",
"explode",
"(",
"col",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"explode",
"(",
"_to_java_column",
"(",
"col",
")",
")",
"return",
"Column",
"(",
"jc",
")"
] | Returns a new row for each element in the given array or map.
Uses the default column name `col` for elements in the array and
`key` and `value` for elements in the map unless specified otherwise.
>>> from pyspark.sql import Row
>>> eDF = spark.createDataFrame([Row(a=1, intlist=[1,2,3], mapfield={"a": ... | [
"Returns",
"a",
"new",
"row",
"for",
"each",
"element",
"in",
"the",
"given",
"array",
"or",
"map",
".",
"Uses",
"the",
"default",
"column",
"name",
"col",
"for",
"elements",
"in",
"the",
"array",
"and",
"key",
"and",
"value",
"for",
"elements",
"in",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2144-L2164 |
19,195 | apache/spark | python/pyspark/sql/functions.py | get_json_object | def get_json_object(col, path):
"""
Extracts json object from a json string based on json path specified, and returns json string
of the extracted json object. It will return null if the input json string is invalid.
:param col: string column in json format
:param path: path to the json object to e... | python | def get_json_object(col, path):
"""
Extracts json object from a json string based on json path specified, and returns json string
of the extracted json object. It will return null if the input json string is invalid.
:param col: string column in json format
:param path: path to the json object to e... | [
"def",
"get_json_object",
"(",
"col",
",",
"path",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"get_json_object",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"path",
")",
"return... | Extracts json object from a json string based on json path specified, and returns json string
of the extracted json object. It will return null if the input json string is invalid.
:param col: string column in json format
:param path: path to the json object to extract
>>> data = [("1", '''{"f1": "val... | [
"Extracts",
"json",
"object",
"from",
"a",
"json",
"string",
"based",
"on",
"json",
"path",
"specified",
"and",
"returns",
"json",
"string",
"of",
"the",
"extracted",
"json",
"object",
".",
"It",
"will",
"return",
"null",
"if",
"the",
"input",
"json",
"str... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2264-L2280 |
19,196 | apache/spark | python/pyspark/sql/functions.py | json_tuple | def json_tuple(col, *fields):
"""Creates a new row for a json column according to the given field names.
:param col: string column in json format
:param fields: list of fields to extract
>>> data = [("1", '''{"f1": "value1", "f2": "value2"}'''), ("2", '''{"f1": "value12"}''')]
>>> df = spark.creat... | python | def json_tuple(col, *fields):
"""Creates a new row for a json column according to the given field names.
:param col: string column in json format
:param fields: list of fields to extract
>>> data = [("1", '''{"f1": "value1", "f2": "value2"}'''), ("2", '''{"f1": "value12"}''')]
>>> df = spark.creat... | [
"def",
"json_tuple",
"(",
"col",
",",
"*",
"fields",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"json_tuple",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"_to_seq",
"(",
"sc",... | Creates a new row for a json column according to the given field names.
:param col: string column in json format
:param fields: list of fields to extract
>>> data = [("1", '''{"f1": "value1", "f2": "value2"}'''), ("2", '''{"f1": "value12"}''')]
>>> df = spark.createDataFrame(data, ("key", "jstring"))
... | [
"Creates",
"a",
"new",
"row",
"for",
"a",
"json",
"column",
"according",
"to",
"the",
"given",
"field",
"names",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2285-L2298 |
19,197 | apache/spark | python/pyspark/sql/functions.py | schema_of_json | def schema_of_json(json, options={}):
"""
Parses a JSON string and infers its schema in DDL format.
:param json: a JSON string or a string literal containing a JSON string.
:param options: options to control parsing. accepts the same options as the JSON datasource
.. versionchanged:: 3.0
It... | python | def schema_of_json(json, options={}):
"""
Parses a JSON string and infers its schema in DDL format.
:param json: a JSON string or a string literal containing a JSON string.
:param options: options to control parsing. accepts the same options as the JSON datasource
.. versionchanged:: 3.0
It... | [
"def",
"schema_of_json",
"(",
"json",
",",
"options",
"=",
"{",
"}",
")",
":",
"if",
"isinstance",
"(",
"json",
",",
"basestring",
")",
":",
"col",
"=",
"_create_column_from_literal",
"(",
"json",
")",
"elif",
"isinstance",
"(",
"json",
",",
"Column",
")... | Parses a JSON string and infers its schema in DDL format.
:param json: a JSON string or a string literal containing a JSON string.
:param options: options to control parsing. accepts the same options as the JSON datasource
.. versionchanged:: 3.0
It accepts `options` parameter to control schema inf... | [
"Parses",
"a",
"JSON",
"string",
"and",
"infers",
"its",
"schema",
"in",
"DDL",
"format",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2393-L2419 |
19,198 | apache/spark | python/pyspark/sql/functions.py | schema_of_csv | def schema_of_csv(csv, options={}):
"""
Parses a CSV string and infers its schema in DDL format.
:param col: a CSV string or a string literal containing a CSV string.
:param options: options to control parsing. accepts the same options as the CSV datasource
>>> df = spark.range(1)
>>> df.selec... | python | def schema_of_csv(csv, options={}):
"""
Parses a CSV string and infers its schema in DDL format.
:param col: a CSV string or a string literal containing a CSV string.
:param options: options to control parsing. accepts the same options as the CSV datasource
>>> df = spark.range(1)
>>> df.selec... | [
"def",
"schema_of_csv",
"(",
"csv",
",",
"options",
"=",
"{",
"}",
")",
":",
"if",
"isinstance",
"(",
"csv",
",",
"basestring",
")",
":",
"col",
"=",
"_create_column_from_literal",
"(",
"csv",
")",
"elif",
"isinstance",
"(",
"csv",
",",
"Column",
")",
... | Parses a CSV string and infers its schema in DDL format.
:param col: a CSV string or a string literal containing a CSV string.
:param options: options to control parsing. accepts the same options as the CSV datasource
>>> df = spark.range(1)
>>> df.select(schema_of_csv(lit('1|a'), {'sep':'|'}).alias("... | [
"Parses",
"a",
"CSV",
"string",
"and",
"infers",
"its",
"schema",
"in",
"DDL",
"format",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2424-L2446 |
19,199 | apache/spark | python/pyspark/sql/functions.py | map_concat | def map_concat(*cols):
"""Returns the union of all the given maps.
:param cols: list of column names (string) or list of :class:`Column` expressions
>>> from pyspark.sql.functions import map_concat
>>> df = spark.sql("SELECT map(1, 'a', 2, 'b') as map1, map(3, 'c', 1, 'd') as map2")
>>> df.select(... | python | def map_concat(*cols):
"""Returns the union of all the given maps.
:param cols: list of column names (string) or list of :class:`Column` expressions
>>> from pyspark.sql.functions import map_concat
>>> df = spark.sql("SELECT map(1, 'a', 2, 'b') as map1, map(3, 'c', 1, 'd') as map2")
>>> df.select(... | [
"def",
"map_concat",
"(",
"*",
"cols",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"len",
"(",
"cols",
")",
"==",
"1",
"and",
"isinstance",
"(",
"cols",
"[",
"0",
"]",
",",
"(",
"list",
",",
"set",
")",
")",
":",
"cols"... | Returns the union of all the given maps.
:param cols: list of column names (string) or list of :class:`Column` expressions
>>> from pyspark.sql.functions import map_concat
>>> df = spark.sql("SELECT map(1, 'a', 2, 'b') as map1, map(3, 'c', 1, 'd') as map2")
>>> df.select(map_concat("map1", "map2").ali... | [
"Returns",
"the",
"union",
"of",
"all",
"the",
"given",
"maps",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2717-L2735 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.