partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | ValidatorParams._from_java_impl | Return Python estimator, estimatorParamMaps, and evaluator from a Java ValidatorParams. | python/pyspark/ml/tuning.py | 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):
"""
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._... | [
"Return",
"Python",
"estimator",
"estimatorParamMaps",
"and",
"evaluator",
"from",
"a",
"Java",
"ValidatorParams",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L173-L183 | [
"def",
"_from_java_impl",
"(",
"cls",
",",
"java_stage",
")",
":",
"# Load information from java_stage to the instance.",
"estimator",
"=",
"JavaParams",
".",
"_from_java",
"(",
"java_stage",
".",
"getEstimator",
"(",
")",
")",
"evaluator",
"=",
"JavaParams",
".",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | ValidatorParams._to_java_impl | Return Java estimator, estimatorParamMaps, and evaluator from this Python instance. | python/pyspark/ml/tuning.py | 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):
"""
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... | [
"Return",
"Java",
"estimator",
"estimatorParamMaps",
"and",
"evaluator",
"from",
"this",
"Python",
"instance",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L185-L199 | [
"def",
"_to_java_impl",
"(",
"self",
")",
":",
"gateway",
"=",
"SparkContext",
".",
"_gateway",
"cls",
"=",
"SparkContext",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",
"ml",
".",
"param",
".",
"ParamMap",
"java_epms",
"=",
"gateway",
".",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | CrossValidator._from_java | Given a Java CrossValidator, create and return a Python wrapper of it.
Used for ML persistence. | python/pyspark/ml/tuning.py | 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):
"""
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 =... | [
"Given",
"a",
"Java",
"CrossValidator",
"create",
"and",
"return",
"a",
"Python",
"wrapper",
"of",
"it",
".",
"Used",
"for",
"ML",
"persistence",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L351-L367 | [
"def",
"_from_java",
"(",
"cls",
",",
"java_stage",
")",
":",
"estimator",
",",
"epms",
",",
"evaluator",
"=",
"super",
"(",
"CrossValidator",
",",
"cls",
")",
".",
"_from_java_impl",
"(",
"java_stage",
")",
"numFolds",
"=",
"java_stage",
".",
"getNumFolds",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | CrossValidator._to_java | Transfer this instance to a Java CrossValidator. Used for ML persistence.
:return: Java object equivalent to this instance. | python/pyspark/ml/tuning.py | 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):
"""
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... | [
"Transfer",
"this",
"instance",
"to",
"a",
"Java",
"CrossValidator",
".",
"Used",
"for",
"ML",
"persistence",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L369-L387 | [
"def",
"_to_java",
"(",
"self",
")",
":",
"estimator",
",",
"epms",
",",
"evaluator",
"=",
"super",
"(",
"CrossValidator",
",",
"self",
")",
".",
"_to_java_impl",
"(",
")",
"_java_obj",
"=",
"JavaParams",
".",
"_new_java_obj",
"(",
"\"org.apache.spark.ml.tunin... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | CrossValidatorModel.copy | 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... | python/pyspark/ml/tuning.py | 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):
"""
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... | [
"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... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L414-L430 | [
"def",
"copy",
"(",
"self",
",",
"extra",
"=",
"None",
")",
":",
"if",
"extra",
"is",
"None",
":",
"extra",
"=",
"dict",
"(",
")",
"bestModel",
"=",
"self",
".",
"bestModel",
".",
"copy",
"(",
"extra",
")",
"avgMetrics",
"=",
"self",
".",
"avgMetri... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | TrainValidationSplit.setParams | setParams(self, estimator=None, estimatorParamMaps=None, evaluator=None, trainRatio=0.75,\
parallelism=1, collectSubModels=False, seed=None):
Sets params for the train validation split. | python/pyspark/ml/tuning.py | def setParams(self, estimator=None, estimatorParamMaps=None, evaluator=None, trainRatio=0.75,
parallelism=1, collectSubModels=False, seed=None):
"""
setParams(self, estimator=None, estimatorParamMaps=None, evaluator=None, trainRatio=0.75,\
parallelism=1, collectSubMod... | def setParams(self, estimator=None, estimatorParamMaps=None, evaluator=None, trainRatio=0.75,
parallelism=1, collectSubModels=False, seed=None):
"""
setParams(self, estimator=None, estimatorParamMaps=None, evaluator=None, trainRatio=0.75,\
parallelism=1, collectSubMod... | [
"setParams",
"(",
"self",
"estimator",
"=",
"None",
"estimatorParamMaps",
"=",
"None",
"evaluator",
"=",
"None",
"trainRatio",
"=",
"0",
".",
"75",
"\\",
"parallelism",
"=",
"1",
"collectSubModels",
"=",
"False",
"seed",
"=",
"None",
")",
":",
"Sets",
"par... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L537-L545 | [
"def",
"setParams",
"(",
"self",
",",
"estimator",
"=",
"None",
",",
"estimatorParamMaps",
"=",
"None",
",",
"evaluator",
"=",
"None",
",",
"trainRatio",
"=",
"0.75",
",",
"parallelism",
"=",
"1",
",",
"collectSubModels",
"=",
"False",
",",
"seed",
"=",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | TrainValidationSplit.copy | 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 | python/pyspark/ml/tuning.py | 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):
"""
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... | [
"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",
... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L598-L615 | [
"def",
"copy",
"(",
"self",
",",
"extra",
"=",
"None",
")",
":",
"if",
"extra",
"is",
"None",
":",
"extra",
"=",
"dict",
"(",
")",
"newTVS",
"=",
"Params",
".",
"copy",
"(",
"self",
",",
"extra",
")",
"if",
"self",
".",
"isSet",
"(",
"self",
".... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | TrainValidationSplit._from_java | Given a Java TrainValidationSplit, create and return a Python wrapper of it.
Used for ML persistence. | python/pyspark/ml/tuning.py | 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):
"""
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(... | [
"Given",
"a",
"Java",
"TrainValidationSplit",
"create",
"and",
"return",
"a",
"Python",
"wrapper",
"of",
"it",
".",
"Used",
"for",
"ML",
"persistence",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L629-L645 | [
"def",
"_from_java",
"(",
"cls",
",",
"java_stage",
")",
":",
"estimator",
",",
"epms",
",",
"evaluator",
"=",
"super",
"(",
"TrainValidationSplit",
",",
"cls",
")",
".",
"_from_java_impl",
"(",
"java_stage",
")",
"trainRatio",
"=",
"java_stage",
".",
"getTr... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | TrainValidationSplit._to_java | Transfer this instance to a Java TrainValidationSplit. Used for ML persistence.
:return: Java object equivalent to this instance. | python/pyspark/ml/tuning.py | def _to_java(self):
"""
Transfer this instance to a Java TrainValidationSplit. Used for ML persistence.
:return: Java object equivalent to this instance.
"""
estimator, epms, evaluator = super(TrainValidationSplit, self)._to_java_impl()
_java_obj = JavaParams._new_java_... | def _to_java(self):
"""
Transfer this instance to a Java TrainValidationSplit. Used for ML persistence.
:return: Java object equivalent to this instance.
"""
estimator, epms, evaluator = super(TrainValidationSplit, self)._to_java_impl()
_java_obj = JavaParams._new_java_... | [
"Transfer",
"this",
"instance",
"to",
"a",
"Java",
"TrainValidationSplit",
".",
"Used",
"for",
"ML",
"persistence",
".",
":",
"return",
":",
"Java",
"object",
"equivalent",
"to",
"this",
"instance",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L647-L664 | [
"def",
"_to_java",
"(",
"self",
")",
":",
"estimator",
",",
"epms",
",",
"evaluator",
"=",
"super",
"(",
"TrainValidationSplit",
",",
"self",
")",
".",
"_to_java_impl",
"(",
")",
"_java_obj",
"=",
"JavaParams",
".",
"_new_java_obj",
"(",
"\"org.apache.spark.ml... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | TrainValidationSplitModel.copy | 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... | python/pyspark/ml/tuning.py | 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):
"""
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 ... | [
"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... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L689-L706 | [
"def",
"copy",
"(",
"self",
",",
"extra",
"=",
"None",
")",
":",
"if",
"extra",
"is",
"None",
":",
"extra",
"=",
"dict",
"(",
")",
"bestModel",
"=",
"self",
".",
"bestModel",
".",
"copy",
"(",
"extra",
")",
"validationMetrics",
"=",
"list",
"(",
"s... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | TrainValidationSplitModel._from_java | Given a Java TrainValidationSplitModel, create and return a Python wrapper of it.
Used for ML persistence. | python/pyspark/ml/tuning.py | 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):
"""
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... | [
"Given",
"a",
"Java",
"TrainValidationSplitModel",
"create",
"and",
"return",
"a",
"Python",
"wrapper",
"of",
"it",
".",
"Used",
"for",
"ML",
"persistence",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L720-L739 | [
"def",
"_from_java",
"(",
"cls",
",",
"java_stage",
")",
":",
"# Load information from java_stage to the instance.",
"bestModel",
"=",
"JavaParams",
".",
"_from_java",
"(",
"java_stage",
".",
"bestModel",
"(",
")",
")",
"estimator",
",",
"epms",
",",
"evaluator",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | TrainValidationSplitModel._to_java | Transfer this instance to a Java TrainValidationSplitModel. Used for ML persistence.
:return: Java object equivalent to this instance. | python/pyspark/ml/tuning.py | def _to_java(self):
"""
Transfer this instance to a Java TrainValidationSplitModel. Used for ML persistence.
:return: Java object equivalent to this instance.
"""
sc = SparkContext._active_spark_context
# TODO: persst validation metrics as well
_java_obj = JavaPa... | def _to_java(self):
"""
Transfer this instance to a Java TrainValidationSplitModel. Used for ML persistence.
:return: Java object equivalent to this instance.
"""
sc = SparkContext._active_spark_context
# TODO: persst validation metrics as well
_java_obj = JavaPa... | [
"Transfer",
"this",
"instance",
"to",
"a",
"Java",
"TrainValidationSplitModel",
".",
"Used",
"for",
"ML",
"persistence",
".",
":",
"return",
":",
"Java",
"object",
"equivalent",
"to",
"this",
"instance",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/tuning.py#L741-L764 | [
"def",
"_to_java",
"(",
"self",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"# TODO: persst validation metrics as well",
"_java_obj",
"=",
"JavaParams",
".",
"_new_java_obj",
"(",
"\"org.apache.spark.ml.tuning.TrainValidationSplitModel\"",
",",
"self",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | RuntimeConfig.get | Returns the value of Spark runtime configuration property for the given key,
assuming it is set. | python/pyspark/sql/conf.py | 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):
"""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... | [
"Returns",
"the",
"value",
"of",
"Spark",
"runtime",
"configuration",
"property",
"for",
"the",
"given",
"key",
"assuming",
"it",
"is",
"set",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/conf.py#L45-L55 | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"default",
"=",
"_NoValue",
")",
":",
"self",
".",
"_checkType",
"(",
"key",
",",
"\"key\"",
")",
"if",
"default",
"is",
"_NoValue",
":",
"return",
"self",
".",
"_jconf",
".",
"get",
"(",
"key",
")",
"els... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | RuntimeConfig._checkType | Assert that an object is of type str. | python/pyspark/sql/conf.py | 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):
"""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__)) | [
"Assert",
"that",
"an",
"object",
"is",
"of",
"type",
"str",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/conf.py#L63-L67 | [
"def",
"_checkType",
"(",
"self",
",",
"obj",
",",
"identifier",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"basestring",
")",
":",
"raise",
"TypeError",
"(",
"\"expected %s '%s' to be a string (was '%s')\"",
"%",
"(",
"identifier",
",",
"obj",
",",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _create_function | Create a PySpark function by its name | python/pyspark/sql/functions.py | 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=""):
"""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 _ | [
"Create",
"a",
"PySpark",
"function",
"by",
"its",
"name"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L47-L55 | [
"def",
"_create_function",
"(",
"name",
",",
"doc",
"=",
"\"\"",
")",
":",
"def",
"_",
"(",
"col",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"getattr",
"(",
"sc",
".",
"_jvm",
".",
"functions",
",",
"name",
")",
"(... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _create_function_over_column | Similar with `_create_function` but creates a PySpark function that takes a column
(as string as well). This is mainly for PySpark functions to take strings as
column names. | python/pyspark/sql/functions.py | def _create_function_over_column(name, doc=""):
"""Similar with `_create_function` but creates a PySpark function that takes a column
(as string as well). This is mainly for PySpark functions to take strings as
column names.
"""
def _(col):
sc = SparkContext._active_spark_context
jc ... | def _create_function_over_column(name, doc=""):
"""Similar with `_create_function` but creates a PySpark function that takes a column
(as string as well). This is mainly for PySpark functions to take strings as
column names.
"""
def _(col):
sc = SparkContext._active_spark_context
jc ... | [
"Similar",
"with",
"_create_function",
"but",
"creates",
"a",
"PySpark",
"function",
"that",
"takes",
"a",
"column",
"(",
"as",
"string",
"as",
"well",
")",
".",
"This",
"is",
"mainly",
"for",
"PySpark",
"functions",
"to",
"take",
"strings",
"as",
"column",
... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L58-L69 | [
"def",
"_create_function_over_column",
"(",
"name",
",",
"doc",
"=",
"\"\"",
")",
":",
"def",
"_",
"(",
"col",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"getattr",
"(",
"sc",
".",
"_jvm",
".",
"functions",
",",
"name",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _wrap_deprecated_function | Wrap the deprecated function to print out deprecation warnings | python/pyspark/sql/functions.py | 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):
""" Wrap the deprecated function to print out deprecation warnings"""
def _(col):
warnings.warn(message, DeprecationWarning)
return func(col)
return functools.wraps(func)(_) | [
"Wrap",
"the",
"deprecated",
"function",
"to",
"print",
"out",
"deprecation",
"warnings"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L72-L77 | [
"def",
"_wrap_deprecated_function",
"(",
"func",
",",
"message",
")",
":",
"def",
"_",
"(",
"col",
")",
":",
"warnings",
".",
"warn",
"(",
"message",
",",
"DeprecationWarning",
")",
"return",
"func",
"(",
"col",
")",
"return",
"functools",
".",
"wraps",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _create_binary_mathfunction | Create a binary mathfunction by name | python/pyspark/sql/functions.py | 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=""):
""" 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... | [
"Create",
"a",
"binary",
"mathfunction",
"by",
"name"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L80-L104 | [
"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... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _create_window_function | Create a window function by name | python/pyspark/sql/functions.py | 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=''):
""" 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 _ | [
"Create",
"a",
"window",
"function",
"by",
"name"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L107-L115 | [
"def",
"_create_window_function",
"(",
"name",
",",
"doc",
"=",
"''",
")",
":",
"def",
"_",
"(",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"getattr",
"(",
"sc",
".",
"_jvm",
".",
"functions",
",",
"name",
")",
"(",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | approx_count_distinct | Aggregate function: returns a new :class:`Column` for approximate distinct count of
column `col`.
:param rsd: maximum estimation error allowed (default = 0.05). For rsd < 0.01, it is more
efficient to use :func:`countDistinct`
>>> df.agg(approx_count_distinct(df.age).alias('distinct_ages')).collec... | python/pyspark/sql/functions.py | def approx_count_distinct(col, rsd=None):
"""Aggregate function: returns a new :class:`Column` for approximate distinct count of
column `col`.
:param rsd: maximum estimation error allowed (default = 0.05). For rsd < 0.01, it is more
efficient to use :func:`countDistinct`
>>> df.agg(approx_coun... | def approx_count_distinct(col, rsd=None):
"""Aggregate function: returns a new :class:`Column` for approximate distinct count of
column `col`.
:param rsd: maximum estimation error allowed (default = 0.05). For rsd < 0.01, it is more
efficient to use :func:`countDistinct`
>>> df.agg(approx_coun... | [
"Aggregate",
"function",
":",
"returns",
"a",
"new",
":",
"class",
":",
"Column",
"for",
"approximate",
"distinct",
"count",
"of",
"column",
"col",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L314-L329 | [
"def",
"approx_count_distinct",
"(",
"col",
",",
"rsd",
"=",
"None",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"rsd",
"is",
"None",
":",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"approx_count_distinct",
"(",
"_to_... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | broadcast | Marks a DataFrame as small enough for use in broadcast joins. | python/pyspark/sql/functions.py | 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):
"""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) | [
"Marks",
"a",
"DataFrame",
"as",
"small",
"enough",
"for",
"use",
"in",
"broadcast",
"joins",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L333-L337 | [
"def",
"broadcast",
"(",
"df",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"DataFrame",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"broadcast",
"(",
"df",
".",
"_jdf",
")",
",",
"df",
".",
"sql_ctx",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | countDistinct | Returns a new :class:`Column` for distinct count of ``col`` or ``cols``.
>>> df.agg(countDistinct(df.age, df.name).alias('c')).collect()
[Row(c=2)]
>>> df.agg(countDistinct("age", "name").alias('c')).collect()
[Row(c=2)] | python/pyspark/sql/functions.py | def countDistinct(col, *cols):
"""Returns a new :class:`Column` for distinct count of ``col`` or ``cols``.
>>> df.agg(countDistinct(df.age, df.name).alias('c')).collect()
[Row(c=2)]
>>> df.agg(countDistinct("age", "name").alias('c')).collect()
[Row(c=2)]
"""
sc = SparkContext._active_spark... | def countDistinct(col, *cols):
"""Returns a new :class:`Column` for distinct count of ``col`` or ``cols``.
>>> df.agg(countDistinct(df.age, df.name).alias('c')).collect()
[Row(c=2)]
>>> df.agg(countDistinct("age", "name").alias('c')).collect()
[Row(c=2)]
"""
sc = SparkContext._active_spark... | [
"Returns",
"a",
"new",
":",
"class",
":",
"Column",
"for",
"distinct",
"count",
"of",
"col",
"or",
"cols",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L421-L432 | [
"def",
"countDistinct",
"(",
"col",
",",
"*",
"cols",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"countDistinct",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"_to_seq",
"(",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | last | Aggregate function: returns the last value in a group.
The function by default returns the last values it sees. It will return the last non-null
value it sees when ignoreNulls is set to true. If all values are null, then null is returned.
.. note:: The function is non-deterministic because its results dep... | python/pyspark/sql/functions.py | def last(col, ignorenulls=False):
"""Aggregate function: returns the last value in a group.
The function by default returns the last values it sees. It will return the last non-null
value it sees when ignoreNulls is set to true. If all values are null, then null is returned.
.. note:: The function is ... | def last(col, ignorenulls=False):
"""Aggregate function: returns the last value in a group.
The function by default returns the last values it sees. It will return the last non-null
value it sees when ignoreNulls is set to true. If all values are null, then null is returned.
.. note:: The function is ... | [
"Aggregate",
"function",
":",
"returns",
"the",
"last",
"value",
"in",
"a",
"group",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L527-L538 | [
"def",
"last",
"(",
"col",
",",
"ignorenulls",
"=",
"False",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"last",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"ignorenulls",
")",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | nanvl | 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")).... | python/pyspark/sql/functions.py | 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):
"""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... | [
"Returns",
"col1",
"if",
"it",
"is",
"not",
"NaN",
"or",
"col2",
"if",
"col1",
"is",
"NaN",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L565-L575 | [
"def",
"nanvl",
"(",
"col1",
",",
"col2",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"nanvl",
"(",
"_to_java_column",
"(",
"col1",
")",
",",
"_to_java_column",
"(",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | rand | Generates a random column with independent and identically distributed (i.i.d.) samples
from U[0.0, 1.0].
.. note:: The function is non-deterministic in general case.
>>> df.withColumn('rand', rand(seed=42) * 3).collect()
[Row(age=2, name=u'Alice', rand=2.4052597283576684),
Row(age=5, name=u'Bob'... | python/pyspark/sql/functions.py | def rand(seed=None):
"""Generates a random column with independent and identically distributed (i.i.d.) samples
from U[0.0, 1.0].
.. note:: The function is non-deterministic in general case.
>>> df.withColumn('rand', rand(seed=42) * 3).collect()
[Row(age=2, name=u'Alice', rand=2.4052597283576684),... | def rand(seed=None):
"""Generates a random column with independent and identically distributed (i.i.d.) samples
from U[0.0, 1.0].
.. note:: The function is non-deterministic in general case.
>>> df.withColumn('rand', rand(seed=42) * 3).collect()
[Row(age=2, name=u'Alice', rand=2.4052597283576684),... | [
"Generates",
"a",
"random",
"column",
"with",
"independent",
"and",
"identically",
"distributed",
"(",
"i",
".",
"i",
".",
"d",
".",
")",
"samples",
"from",
"U",
"[",
"0",
".",
"0",
"1",
".",
"0",
"]",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L580-L595 | [
"def",
"rand",
"(",
"seed",
"=",
"None",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"seed",
"is",
"not",
"None",
":",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"rand",
"(",
"seed",
")",
"else",
":",
"jc",
"=... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | round | Round the given value to `scale` decimal places using HALF_UP rounding mode if `scale` >= 0
or at integral part when `scale` < 0.
>>> spark.createDataFrame([(2.5,)], ['a']).select(round('a', 0).alias('r')).collect()
[Row(r=3.0)] | python/pyspark/sql/functions.py | def round(col, scale=0):
"""
Round the given value to `scale` decimal places using HALF_UP rounding mode if `scale` >= 0
or at integral part when `scale` < 0.
>>> spark.createDataFrame([(2.5,)], ['a']).select(round('a', 0).alias('r')).collect()
[Row(r=3.0)]
"""
sc = SparkContext._active_spa... | def round(col, scale=0):
"""
Round the given value to `scale` decimal places using HALF_UP rounding mode if `scale` >= 0
or at integral part when `scale` < 0.
>>> spark.createDataFrame([(2.5,)], ['a']).select(round('a', 0).alias('r')).collect()
[Row(r=3.0)]
"""
sc = SparkContext._active_spa... | [
"Round",
"the",
"given",
"value",
"to",
"scale",
"decimal",
"places",
"using",
"HALF_UP",
"rounding",
"mode",
"if",
"scale",
">",
"=",
"0",
"or",
"at",
"integral",
"part",
"when",
"scale",
"<",
"0",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L619-L628 | [
"def",
"round",
"(",
"col",
",",
"scale",
"=",
"0",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"round",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"scale",
")... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | shiftLeft | Shift the given value numBits left.
>>> spark.createDataFrame([(21,)], ['a']).select(shiftLeft('a', 1).alias('r')).collect()
[Row(r=42)] | python/pyspark/sql/functions.py | 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):
"""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)) | [
"Shift",
"the",
"given",
"value",
"numBits",
"left",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L645-L652 | [
"def",
"shiftLeft",
"(",
"col",
",",
"numBits",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"shiftLeft",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"numBits",
")",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | shiftRight | (Signed) shift the given value numBits right.
>>> spark.createDataFrame([(42,)], ['a']).select(shiftRight('a', 1).alias('r')).collect()
[Row(r=21)] | python/pyspark/sql/functions.py | def shiftRight(col, numBits):
"""(Signed) shift the given value numBits right.
>>> spark.createDataFrame([(42,)], ['a']).select(shiftRight('a', 1).alias('r')).collect()
[Row(r=21)]
"""
sc = SparkContext._active_spark_context
jc = sc._jvm.functions.shiftRight(_to_java_column(col), numBits)
r... | def shiftRight(col, numBits):
"""(Signed) shift the given value numBits right.
>>> spark.createDataFrame([(42,)], ['a']).select(shiftRight('a', 1).alias('r')).collect()
[Row(r=21)]
"""
sc = SparkContext._active_spark_context
jc = sc._jvm.functions.shiftRight(_to_java_column(col), numBits)
r... | [
"(",
"Signed",
")",
"shift",
"the",
"given",
"value",
"numBits",
"right",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L656-L664 | [
"def",
"shiftRight",
"(",
"col",
",",
"numBits",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"shiftRight",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"numBits",
")",
"return",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | expr | Parses the expression string into the column that it represents
>>> df.select(expr("length(name)")).collect()
[Row(length(name)=5), Row(length(name)=3)] | python/pyspark/sql/functions.py | 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):
"""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)) | [
"Parses",
"the",
"expression",
"string",
"into",
"the",
"column",
"that",
"it",
"represents"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L694-L701 | [
"def",
"expr",
"(",
"str",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"expr",
"(",
"str",
")",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | when | Evaluates a list of conditions and returns one of multiple possible result expressions.
If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions.
:param condition: a boolean :class:`Column` expression.
:param value: a literal value, or a :class:`Column` expression.
>>> df.... | python/pyspark/sql/functions.py | def when(condition, value):
"""Evaluates a list of conditions and returns one of multiple possible result expressions.
If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions.
:param condition: a boolean :class:`Column` expression.
:param value: a literal value, or a :clas... | def when(condition, value):
"""Evaluates a list of conditions and returns one of multiple possible result expressions.
If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions.
:param condition: a boolean :class:`Column` expression.
:param value: a literal value, or a :clas... | [
"Evaluates",
"a",
"list",
"of",
"conditions",
"and",
"returns",
"one",
"of",
"multiple",
"possible",
"result",
"expressions",
".",
"If",
":",
"func",
":",
"Column",
".",
"otherwise",
"is",
"not",
"invoked",
"None",
"is",
"returned",
"for",
"unmatched",
"cond... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L756-L774 | [
"def",
"when",
"(",
"condition",
",",
"value",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"not",
"isinstance",
"(",
"condition",
",",
"Column",
")",
":",
"raise",
"TypeError",
"(",
"\"condition should be a Column\"",
")",
"v",
"="... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | log | 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'... | python/pyspark/sql/functions.py | 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):
"""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']
>>... | [
"Returns",
"the",
"first",
"argument",
"-",
"based",
"logarithm",
"of",
"the",
"second",
"argument",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L778-L794 | [
"def",
"log",
"(",
"arg1",
",",
"arg2",
"=",
"None",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"arg2",
"is",
"None",
":",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"log",
"(",
"_to_java_column",
"(",
"arg1",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | conv | 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')] | python/pyspark/sql/functions.py | 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):
"""
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._... | [
"Convert",
"a",
"number",
"in",
"a",
"string",
"column",
"from",
"one",
"base",
"to",
"another",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L810-L819 | [
"def",
"conv",
"(",
"col",
",",
"fromBase",
",",
"toBase",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"conv",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"fromBa... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | lag | Window function: returns the value that is `offset` rows before the current row, and
`defaultValue` if there is less than `offset` rows before the current row. For example,
an `offset` of one will return the previous row at any given point in the window partition.
This is equivalent to the LAG function in ... | python/pyspark/sql/functions.py | def lag(col, offset=1, default=None):
"""
Window function: returns the value that is `offset` rows before the current row, and
`defaultValue` if there is less than `offset` rows before the current row. For example,
an `offset` of one will return the previous row at any given point in the window partitio... | def lag(col, offset=1, default=None):
"""
Window function: returns the value that is `offset` rows before the current row, and
`defaultValue` if there is less than `offset` rows before the current row. For example,
an `offset` of one will return the previous row at any given point in the window partitio... | [
"Window",
"function",
":",
"returns",
"the",
"value",
"that",
"is",
"offset",
"rows",
"before",
"the",
"current",
"row",
"and",
"defaultValue",
"if",
"there",
"is",
"less",
"than",
"offset",
"rows",
"before",
"the",
"current",
"row",
".",
"For",
"example",
... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L838-L851 | [
"def",
"lag",
"(",
"col",
",",
"offset",
"=",
"1",
",",
"default",
"=",
"None",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"lag",
"(",
"_to_java_column",
"(",
"c... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | ntile | Window function: returns the ntile group id (from 1 to `n` inclusive)
in an ordered window partition. For example, if `n` is 4, the first
quarter of the rows will get value 1, the second quarter will get 2,
the third quarter will get 3, and the last quarter will get 4.
This is equivalent to the NTILE f... | python/pyspark/sql/functions.py | def ntile(n):
"""
Window function: returns the ntile group id (from 1 to `n` inclusive)
in an ordered window partition. For example, if `n` is 4, the first
quarter of the rows will get value 1, the second quarter will get 2,
the third quarter will get 3, and the last quarter will get 4.
This is... | def ntile(n):
"""
Window function: returns the ntile group id (from 1 to `n` inclusive)
in an ordered window partition. For example, if `n` is 4, the first
quarter of the rows will get value 1, the second quarter will get 2,
the third quarter will get 3, and the last quarter will get 4.
This is... | [
"Window",
"function",
":",
"returns",
"the",
"ntile",
"group",
"id",
"(",
"from",
"1",
"to",
"n",
"inclusive",
")",
"in",
"an",
"ordered",
"window",
"partition",
".",
"For",
"example",
"if",
"n",
"is",
"4",
"the",
"first",
"quarter",
"of",
"the",
"rows... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L872-L884 | [
"def",
"ntile",
"(",
"n",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"ntile",
"(",
"int",
"(",
"n",
")",
")",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | date_format | Converts a date/timestamp/string to a value of string in the format specified by the date
format given by the second argument.
A pattern could be for instance `dd.MM.yyyy` and could return a string like '18.03.1993'. All
pattern letters of the Java class `java.time.format.DateTimeFormatter` can be used.
... | python/pyspark/sql/functions.py | def date_format(date, format):
"""
Converts a date/timestamp/string to a value of string in the format specified by the date
format given by the second argument.
A pattern could be for instance `dd.MM.yyyy` and could return a string like '18.03.1993'. All
pattern letters of the Java class `java.tim... | def date_format(date, format):
"""
Converts a date/timestamp/string to a value of string in the format specified by the date
format given by the second argument.
A pattern could be for instance `dd.MM.yyyy` and could return a string like '18.03.1993'. All
pattern letters of the Java class `java.tim... | [
"Converts",
"a",
"date",
"/",
"timestamp",
"/",
"string",
"to",
"a",
"value",
"of",
"string",
"in",
"the",
"format",
"specified",
"by",
"the",
"date",
"format",
"given",
"by",
"the",
"second",
"argument",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L908-L924 | [
"def",
"date_format",
"(",
"date",
",",
"format",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"date_format",
"(",
"_to_java_column",
"(",
"date",
")",
",",
"format",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | date_add | 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))] | python/pyspark/sql/functions.py | 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):
"""
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
... | [
"Returns",
"the",
"date",
"that",
"is",
"days",
"days",
"after",
"start"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1058-L1067 | [
"def",
"date_add",
"(",
"start",
",",
"days",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"date_add",
"(",
"_to_java_column",
"(",
"start",
")",
",",
"days",
")",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | datediff | 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)] | python/pyspark/sql/functions.py | 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):
"""
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... | [
"Returns",
"the",
"number",
"of",
"days",
"from",
"start",
"to",
"end",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1084-L1093 | [
"def",
"datediff",
"(",
"end",
",",
"start",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"datediff",
"(",
"_to_java_column",
"(",
"end",
")",
",",
"_to_java_column",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | add_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))] | python/pyspark/sql/functions.py | 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):
"""
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... | [
"Returns",
"the",
"date",
"that",
"is",
"months",
"months",
"after",
"start"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1097-L1106 | [
"def",
"add_months",
"(",
"start",
",",
"months",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"add_months",
"(",
"_to_java_column",
"(",
"start",
")",
",",
"months",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | months_between | Returns number of months between dates date1 and date2.
If date1 is later than date2, then the result is positive.
If date1 and date2 are on the same day of month, or both are the last day of month,
returns an integer (time of day will be ignored).
The result is rounded off to 8 digits unless `roundOff`... | python/pyspark/sql/functions.py | def months_between(date1, date2, roundOff=True):
"""
Returns number of months between dates date1 and date2.
If date1 is later than date2, then the result is positive.
If date1 and date2 are on the same day of month, or both are the last day of month,
returns an integer (time of day will be ignored)... | def months_between(date1, date2, roundOff=True):
"""
Returns number of months between dates date1 and date2.
If date1 is later than date2, then the result is positive.
If date1 and date2 are on the same day of month, or both are the last day of month,
returns an integer (time of day will be ignored)... | [
"Returns",
"number",
"of",
"months",
"between",
"dates",
"date1",
"and",
"date2",
".",
"If",
"date1",
"is",
"later",
"than",
"date2",
"then",
"the",
"result",
"is",
"positive",
".",
"If",
"date1",
"and",
"date2",
"are",
"on",
"the",
"same",
"day",
"of",
... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1110-L1126 | [
"def",
"months_between",
"(",
"date1",
",",
"date2",
",",
"roundOff",
"=",
"True",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"months_between",
"(",
"_to_java_column",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | to_date | Converts a :class:`Column` of :class:`pyspark.sql.types.StringType` or
:class:`pyspark.sql.types.TimestampType` into :class:`pyspark.sql.types.DateType`
using the optionally specified format. Specify formats according to
`DateTimeFormatter <https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTime... | python/pyspark/sql/functions.py | def to_date(col, format=None):
"""Converts a :class:`Column` of :class:`pyspark.sql.types.StringType` or
:class:`pyspark.sql.types.TimestampType` into :class:`pyspark.sql.types.DateType`
using the optionally specified format. Specify formats according to
`DateTimeFormatter <https://docs.oracle.com/javas... | def to_date(col, format=None):
"""Converts a :class:`Column` of :class:`pyspark.sql.types.StringType` or
:class:`pyspark.sql.types.TimestampType` into :class:`pyspark.sql.types.DateType`
using the optionally specified format. Specify formats according to
`DateTimeFormatter <https://docs.oracle.com/javas... | [
"Converts",
"a",
":",
"class",
":",
"Column",
"of",
":",
"class",
":",
"pyspark",
".",
"sql",
".",
"types",
".",
"StringType",
"or",
":",
"class",
":",
"pyspark",
".",
"sql",
".",
"types",
".",
"TimestampType",
"into",
":",
"class",
":",
"pyspark",
"... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1130-L1151 | [
"def",
"to_date",
"(",
"col",
",",
"format",
"=",
"None",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"format",
"is",
"None",
":",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"to_date",
"(",
"_to_java_column",
"(",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | date_trunc | 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... | python/pyspark/sql/functions.py | 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):
"""
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'])
>>... | [
"Returns",
"timestamp",
"truncated",
"to",
"the",
"unit",
"specified",
"by",
"the",
"format",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1197-L1211 | [
"def",
"date_trunc",
"(",
"format",
",",
"timestamp",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"date_trunc",
"(",
"format",
",",
"_to_java_column",
"(",
"timestamp",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | next_day | 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(... | python/pyspark/sql/functions.py | 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):
"""
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... | [
"Returns",
"the",
"first",
"date",
"which",
"is",
"later",
"than",
"the",
"value",
"of",
"the",
"date",
"column",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1215-L1227 | [
"def",
"next_day",
"(",
"date",
",",
"dayOfWeek",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"next_day",
"(",
"_to_java_column",
"(",
"date",
")",
",",
"dayOfWeek",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | last_day | 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))] | python/pyspark/sql/functions.py | 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):
"""
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... | [
"Returns",
"the",
"last",
"day",
"of",
"the",
"month",
"which",
"the",
"given",
"date",
"belongs",
"to",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1231-L1240 | [
"def",
"last_day",
"(",
"date",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"last_day",
"(",
"_to_java_column",
"(",
"date",
")",
")",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | unix_timestamp | Convert time string with given pattern ('yyyy-MM-dd HH:mm:ss', by default)
to Unix time stamp (in seconds), using the default timezone and the default
locale, return null if fail.
if `timestamp` is None, then it returns current timestamp.
>>> spark.conf.set("spark.sql.session.timeZone", "America/Los_A... | python/pyspark/sql/functions.py | def unix_timestamp(timestamp=None, format='yyyy-MM-dd HH:mm:ss'):
"""
Convert time string with given pattern ('yyyy-MM-dd HH:mm:ss', by default)
to Unix time stamp (in seconds), using the default timezone and the default
locale, return null if fail.
if `timestamp` is None, then it returns current t... | def unix_timestamp(timestamp=None, format='yyyy-MM-dd HH:mm:ss'):
"""
Convert time string with given pattern ('yyyy-MM-dd HH:mm:ss', by default)
to Unix time stamp (in seconds), using the default timezone and the default
locale, return null if fail.
if `timestamp` is None, then it returns current t... | [
"Convert",
"time",
"string",
"with",
"given",
"pattern",
"(",
"yyyy",
"-",
"MM",
"-",
"dd",
"HH",
":",
"mm",
":",
"ss",
"by",
"default",
")",
"to",
"Unix",
"time",
"stamp",
"(",
"in",
"seconds",
")",
"using",
"the",
"default",
"timezone",
"and",
"the... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1262-L1279 | [
"def",
"unix_timestamp",
"(",
"timestamp",
"=",
"None",
",",
"format",
"=",
"'yyyy-MM-dd HH:mm:ss'",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"timestamp",
"is",
"None",
":",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"fu... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | from_utc_timestamp | 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... | python/pyspark/sql/functions.py | 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):
"""
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... | [
"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... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1283-L1316 | [
"def",
"from_utc_timestamp",
"(",
"timestamp",
",",
"tz",
")",
":",
"warnings",
".",
"warn",
"(",
"\"Deprecated in 3.0. See SPARK-25496\"",
",",
"DeprecationWarning",
")",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"isinstance",
"(",
"tz",
",",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | window | Bucketize rows into one or more time windows given a timestamp specifying column. Window
starts are inclusive but the window ends are exclusive, e.g. 12:05 will be in the window
[12:05,12:10) but not in [12:00,12:05). Windows can support microsecond precision. Windows in
the order of months are not supporte... | python/pyspark/sql/functions.py | def window(timeColumn, windowDuration, slideDuration=None, startTime=None):
"""Bucketize rows into one or more time windows given a timestamp specifying column. Window
starts are inclusive but the window ends are exclusive, e.g. 12:05 will be in the window
[12:05,12:10) but not in [12:00,12:05). Windows can... | def window(timeColumn, windowDuration, slideDuration=None, startTime=None):
"""Bucketize rows into one or more time windows given a timestamp specifying column. Window
starts are inclusive but the window ends are exclusive, e.g. 12:05 will be in the window
[12:05,12:10) but not in [12:00,12:05). Windows can... | [
"Bucketize",
"rows",
"into",
"one",
"or",
"more",
"time",
"windows",
"given",
"a",
"timestamp",
"specifying",
"column",
".",
"Window",
"starts",
"are",
"inclusive",
"but",
"the",
"window",
"ends",
"are",
"exclusive",
"e",
".",
"g",
".",
"12",
":",
"05",
... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1358-L1402 | [
"def",
"window",
"(",
"timeColumn",
",",
"windowDuration",
",",
"slideDuration",
"=",
"None",
",",
"startTime",
"=",
"None",
")",
":",
"def",
"check_string_field",
"(",
"field",
",",
"fieldName",
")",
":",
"if",
"not",
"field",
"or",
"type",
"(",
"field",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | hash | 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)] | python/pyspark/sql/functions.py | 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):
"""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... | [
"Calculates",
"the",
"hash",
"code",
"of",
"given",
"columns",
"and",
"returns",
"the",
"result",
"as",
"an",
"int",
"column",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1466-L1474 | [
"def",
"hash",
"(",
"*",
"cols",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"hash",
"(",
"_to_seq",
"(",
"sc",
",",
"cols",
",",
"_to_java_column",
")",
")",
"return",
"Column... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | concat_ws | 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/pyspark/sql/functions.py | 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):
"""
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",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1511-L1521 | [
"def",
"concat_ws",
"(",
"sep",
",",
"*",
"cols",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"concat_ws",
"(",
"sep",
",",
"_to_seq",
"(",
"sc",
",",
"cols",
","... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | decode | Computes the first argument into a string from a binary using the provided character set
(one of 'US-ASCII', 'ISO-8859-1', 'UTF-8', 'UTF-16BE', 'UTF-16LE', 'UTF-16'). | python/pyspark/sql/functions.py | def decode(col, charset):
"""
Computes the first argument into a string from a binary using the provided character set
(one of 'US-ASCII', 'ISO-8859-1', 'UTF-8', 'UTF-16BE', 'UTF-16LE', 'UTF-16').
"""
sc = SparkContext._active_spark_context
return Column(sc._jvm.functions.decode(_to_java_column(... | def decode(col, charset):
"""
Computes the first argument into a string from a binary using the provided character set
(one of 'US-ASCII', 'ISO-8859-1', 'UTF-8', 'UTF-16BE', 'UTF-16LE', 'UTF-16').
"""
sc = SparkContext._active_spark_context
return Column(sc._jvm.functions.decode(_to_java_column(... | [
"Computes",
"the",
"first",
"argument",
"into",
"a",
"string",
"from",
"a",
"binary",
"using",
"the",
"provided",
"character",
"set",
"(",
"one",
"of",
"US",
"-",
"ASCII",
"ISO",
"-",
"8859",
"-",
"1",
"UTF",
"-",
"8",
"UTF",
"-",
"16BE",
"UTF",
"-",... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1525-L1531 | [
"def",
"decode",
"(",
"col",
",",
"charset",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"decode",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"charset",
")",
")"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | format_number | Formats the number X to a format like '#,--#,--#.--', rounded to d decimal places
with HALF_EVEN round mode, and returns the result as a string.
:param col: the column name of the numeric value to be formatted
:param d: the N decimal places
>>> spark.createDataFrame([(5,)], ['a']).select(format_number... | python/pyspark/sql/functions.py | def format_number(col, d):
"""
Formats the number X to a format like '#,--#,--#.--', rounded to d decimal places
with HALF_EVEN round mode, and returns the result as a string.
:param col: the column name of the numeric value to be formatted
:param d: the N decimal places
>>> spark.createDataFr... | def format_number(col, d):
"""
Formats the number X to a format like '#,--#,--#.--', rounded to d decimal places
with HALF_EVEN round mode, and returns the result as a string.
:param col: the column name of the numeric value to be formatted
:param d: the N decimal places
>>> spark.createDataFr... | [
"Formats",
"the",
"number",
"X",
"to",
"a",
"format",
"like",
"#",
"--",
"#",
"--",
"#",
".",
"--",
"rounded",
"to",
"d",
"decimal",
"places",
"with",
"HALF_EVEN",
"round",
"mode",
"and",
"returns",
"the",
"result",
"as",
"a",
"string",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1546-L1558 | [
"def",
"format_number",
"(",
"col",
",",
"d",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"format_number",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"d",
")",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | format_string | 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... | python/pyspark/sql/functions.py | 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):
"""
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... | [
"Formats",
"the",
"arguments",
"in",
"printf",
"-",
"style",
"and",
"returns",
"the",
"result",
"as",
"a",
"string",
"column",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1563-L1575 | [
"def",
"format_string",
"(",
"format",
",",
"*",
"cols",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"format_string",
"(",
"format",
",",
"_to_seq",
"(",
"sc",
",",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | instr | 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',])
>>... | python/pyspark/sql/functions.py | 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):
"""
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... | [
"Locate",
"the",
"position",
"of",
"the",
"first",
"occurrence",
"of",
"substr",
"column",
"in",
"the",
"given",
"string",
".",
"Returns",
"null",
"if",
"either",
"of",
"the",
"arguments",
"are",
"null",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1579-L1592 | [
"def",
"instr",
"(",
"str",
",",
"substr",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"instr",
"(",
"_to_java_column",
"(",
"str",
")",
",",
"substr",
")",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | substring | 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',])
... | python/pyspark/sql/functions.py | 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):
"""
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... | [
"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... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1597-L1610 | [
"def",
"substring",
"(",
"str",
",",
"pos",
",",
"len",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"substring",
"(",
"_to_java_column",
"(",
"str",
")",
",",
"pos"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | substring_index | Returns the substring from string str before count occurrences of the delimiter delim.
If count is positive, everything the left of the final delimiter (counting from left) is
returned. If count is negative, every to the right of the final delimiter (counting from the
right) is returned. substring_index per... | python/pyspark/sql/functions.py | def substring_index(str, delim, count):
"""
Returns the substring from string str before count occurrences of the delimiter delim.
If count is positive, everything the left of the final delimiter (counting from left) is
returned. If count is negative, every to the right of the final delimiter (counting ... | def substring_index(str, delim, count):
"""
Returns the substring from string str before count occurrences of the delimiter delim.
If count is positive, everything the left of the final delimiter (counting from left) is
returned. If count is negative, every to the right of the final delimiter (counting ... | [
"Returns",
"the",
"substring",
"from",
"string",
"str",
"before",
"count",
"occurrences",
"of",
"the",
"delimiter",
"delim",
".",
"If",
"count",
"is",
"positive",
"everything",
"the",
"left",
"of",
"the",
"final",
"delimiter",
"(",
"counting",
"from",
"left",
... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1615-L1629 | [
"def",
"substring_index",
"(",
"str",
",",
"delim",
",",
"count",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"substring_index",
"(",
"_to_java_column",
"(",
"str",
")"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | levenshtein | 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)] | python/pyspark/sql/functions.py | 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):
"""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... | [
"Computes",
"the",
"Levenshtein",
"distance",
"of",
"the",
"two",
"given",
"strings",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1634-L1643 | [
"def",
"levenshtein",
"(",
"left",
",",
"right",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"levenshtein",
"(",
"_to_java_column",
"(",
"left",
")",
",",
"_to_java_column",
"(",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | locate | 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... | python/pyspark/sql/functions.py | 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):
"""
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... | [
"Locate",
"the",
"position",
"of",
"the",
"first",
"occurrence",
"of",
"substr",
"in",
"a",
"string",
"column",
"after",
"position",
"pos",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1647-L1663 | [
"def",
"locate",
"(",
"substr",
",",
"str",
",",
"pos",
"=",
"1",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"locate",
"(",
"substr",
",",
"_to_java_column",
"(",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | lpad | 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')] | python/pyspark/sql/functions.py | 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):
"""
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... | [
"Left",
"-",
"pad",
"the",
"string",
"column",
"to",
"width",
"len",
"with",
"pad",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1668-L1677 | [
"def",
"lpad",
"(",
"col",
",",
"len",
",",
"pad",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"lpad",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"len",
",",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | repeat | 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')] | python/pyspark/sql/functions.py | 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):
"""
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... | [
"Repeats",
"a",
"string",
"column",
"n",
"times",
"and",
"returns",
"it",
"as",
"a",
"new",
"string",
"column",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1696-L1705 | [
"def",
"repeat",
"(",
"col",
",",
"n",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"repeat",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"n",
")",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | split | 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... | python/pyspark/sql/functions.py | 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):
"""
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... | [
"Splits",
"str",
"around",
"matches",
"of",
"the",
"given",
"pattern",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1710-L1735 | [
"def",
"split",
"(",
"str",
",",
"pattern",
",",
"limit",
"=",
"-",
"1",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"split",
"(",
"_to_java_column",
"(",
"str",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | regexp_extract | 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... | python/pyspark/sql/functions.py | 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):
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... | [
"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... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1740-L1756 | [
"def",
"regexp_extract",
"(",
"str",
",",
"pattern",
",",
"idx",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"regexp_extract",
"(",
"_to_java_column",
"(",
"str",
")",
",",
"patter... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | regexp_replace | 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'-----')] | python/pyspark/sql/functions.py | 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):
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... | [
"r",
"Replace",
"all",
"substrings",
"of",
"the",
"specified",
"string",
"value",
"that",
"match",
"regexp",
"with",
"rep",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1761-L1770 | [
"def",
"regexp_replace",
"(",
"str",
",",
"pattern",
",",
"replacement",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"regexp_replace",
"(",
"_to_java_column",
"(",
"str",
")",
",",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | 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 happen when any character in the string matching with the character
in the `matching`.
>>> spark.createDataFrame([('translate... | python/pyspark/sql/functions.py | 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):
"""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... | [
"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",
... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1856-L1867 | [
"def",
"translate",
"(",
"srcCol",
",",
"matching",
",",
"replace",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"translate",
"(",
"_to_java_column",
"(",
"srcCol",
")",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | arrays_overlap | Collection function: returns true if the arrays contain any common non-null element; if not,
returns null if both the arrays are non-empty and any of them contains a null element; returns
false otherwise.
>>> df = spark.createDataFrame([(["a", "b"], ["b", "c"]), (["a"], ["b", "c"])], ['x', 'y'])
>>> df... | python/pyspark/sql/functions.py | def arrays_overlap(a1, a2):
"""
Collection function: returns true if the arrays contain any common non-null element; if not,
returns null if both the arrays are non-empty and any of them contains a null element; returns
false otherwise.
>>> df = spark.createDataFrame([(["a", "b"], ["b", "c"]), (["a... | def arrays_overlap(a1, a2):
"""
Collection function: returns true if the arrays contain any common non-null element; if not,
returns null if both the arrays are non-empty and any of them contains a null element; returns
false otherwise.
>>> df = spark.createDataFrame([(["a", "b"], ["b", "c"]), (["a... | [
"Collection",
"function",
":",
"returns",
"true",
"if",
"the",
"arrays",
"contain",
"any",
"common",
"non",
"-",
"null",
"element",
";",
"if",
"not",
"returns",
"null",
"if",
"both",
"the",
"arrays",
"are",
"non",
"-",
"empty",
"and",
"any",
"of",
"them"... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1948-L1959 | [
"def",
"arrays_overlap",
"(",
"a1",
",",
"a2",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"arrays_overlap",
"(",
"_to_java_column",
"(",
"a1",
")",
",",
"_to_java_colu... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | slice | Collection function: returns an array containing all the elements in `x` from index `start`
(or starting from the end if `start` is negative) with the specified `length`.
>>> df = spark.createDataFrame([([1, 2, 3],), ([4, 5],)], ['x'])
>>> df.select(slice(df.x, 2, 2).alias("sliced")).collect()
[Row(sli... | python/pyspark/sql/functions.py | def slice(x, start, length):
"""
Collection function: returns an array containing all the elements in `x` from index `start`
(or starting from the end if `start` is negative) with the specified `length`.
>>> df = spark.createDataFrame([([1, 2, 3],), ([4, 5],)], ['x'])
>>> df.select(slice(df.x, 2, 2... | def slice(x, start, length):
"""
Collection function: returns an array containing all the elements in `x` from index `start`
(or starting from the end if `start` is negative) with the specified `length`.
>>> df = spark.createDataFrame([([1, 2, 3],), ([4, 5],)], ['x'])
>>> df.select(slice(df.x, 2, 2... | [
"Collection",
"function",
":",
"returns",
"an",
"array",
"containing",
"all",
"the",
"elements",
"in",
"x",
"from",
"index",
"start",
"(",
"or",
"starting",
"from",
"the",
"end",
"if",
"start",
"is",
"negative",
")",
"with",
"the",
"specified",
"length",
"... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1963-L1972 | [
"def",
"slice",
"(",
"x",
",",
"start",
",",
"length",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"slice",
"(",
"_to_java_column",
"(",
"x",
")",
",",
"start",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | array_join | 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=... | python/pyspark/sql/functions.py | 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):
"""
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... | [
"Concatenates",
"the",
"elements",
"of",
"column",
"using",
"the",
"delimiter",
".",
"Null",
"values",
"are",
"replaced",
"with",
"null_replacement",
"if",
"set",
"otherwise",
"they",
"are",
"ignored",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1977-L1993 | [
"def",
"array_join",
"(",
"col",
",",
"delimiter",
",",
"null_replacement",
"=",
"None",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"null_replacement",
"is",
"None",
":",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functio... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | concat | 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... | python/pyspark/sql/functions.py | 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):
"""
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')]... | [
"Concatenates",
"multiple",
"input",
"columns",
"together",
"into",
"a",
"single",
"column",
".",
"The",
"function",
"works",
"with",
"strings",
"binary",
"and",
"compatible",
"array",
"columns",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L1998-L2012 | [
"def",
"concat",
"(",
"*",
"cols",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"concat",
"(",
"_to_seq",
"(",
"sc",
",",
"cols",
",",
"_to_java_column",
")",
")",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | array_position | Collection function: Locates the position of the first occurrence of the given value
in the given array. Returns null if either of the arguments are null.
.. note:: The position is not zero based, but 1 based index. Returns 0 if the given
value could not be found in the array.
>>> df = spark.creat... | python/pyspark/sql/functions.py | def array_position(col, value):
"""
Collection function: Locates the position of the first occurrence of the given value
in the given array. Returns null if either of the arguments are null.
.. note:: The position is not zero based, but 1 based index. Returns 0 if the given
value could not be f... | def array_position(col, value):
"""
Collection function: Locates the position of the first occurrence of the given value
in the given array. Returns null if either of the arguments are null.
.. note:: The position is not zero based, but 1 based index. Returns 0 if the given
value could not be f... | [
"Collection",
"function",
":",
"Locates",
"the",
"position",
"of",
"the",
"first",
"occurrence",
"of",
"the",
"given",
"value",
"in",
"the",
"given",
"array",
".",
"Returns",
"null",
"if",
"either",
"of",
"the",
"arguments",
"are",
"null",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2016-L2029 | [
"def",
"array_position",
"(",
"col",
",",
"value",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"array_position",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"value",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | element_at | Collection function: Returns element of array at given index in extraction if col is array.
Returns value for the given key in extraction if col is map.
:param col: name of column containing array or map
:param extraction: index to check for in array or key to check for in map
.. note:: The position i... | python/pyspark/sql/functions.py | def element_at(col, extraction):
"""
Collection function: Returns element of array at given index in extraction if col is array.
Returns value for the given key in extraction if col is map.
:param col: name of column containing array or map
:param extraction: index to check for in array or key to c... | def element_at(col, extraction):
"""
Collection function: Returns element of array at given index in extraction if col is array.
Returns value for the given key in extraction if col is map.
:param col: name of column containing array or map
:param extraction: index to check for in array or key to c... | [
"Collection",
"function",
":",
"Returns",
"element",
"of",
"array",
"at",
"given",
"index",
"in",
"extraction",
"if",
"col",
"is",
"array",
".",
"Returns",
"value",
"for",
"the",
"given",
"key",
"in",
"extraction",
"if",
"col",
"is",
"map",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2034-L2053 | [
"def",
"element_at",
"(",
"col",
",",
"extraction",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"element_at",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"extraction"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | array_remove | Collection function: Remove all elements that equal to element from the given array.
:param col: name of column containing array
:param element: element to be removed from the array
>>> df = spark.createDataFrame([([1, 2, 3, 1, 1],), ([],)], ['data'])
>>> df.select(array_remove(df.data, 1)).collect()
... | python/pyspark/sql/functions.py | def array_remove(col, element):
"""
Collection function: Remove all elements that equal to element from the given array.
:param col: name of column containing array
:param element: element to be removed from the array
>>> df = spark.createDataFrame([([1, 2, 3, 1, 1],), ([],)], ['data'])
>>> df... | def array_remove(col, element):
"""
Collection function: Remove all elements that equal to element from the given array.
:param col: name of column containing array
:param element: element to be removed from the array
>>> df = spark.createDataFrame([([1, 2, 3, 1, 1],), ([],)], ['data'])
>>> df... | [
"Collection",
"function",
":",
"Remove",
"all",
"elements",
"that",
"equal",
"to",
"element",
"from",
"the",
"given",
"array",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2057-L2069 | [
"def",
"array_remove",
"(",
"col",
",",
"element",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"array_remove",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"element",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | explode | 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": ... | python/pyspark/sql/functions.py | 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):
"""
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... | [
"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",
... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2144-L2164 | [
"def",
"explode",
"(",
"col",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"explode",
"(",
"_to_java_column",
"(",
"col",
")",
")",
"return",
"Column",
"(",
"jc",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | get_json_object | 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... | python/pyspark/sql/functions.py | 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):
"""
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... | [
"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... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2264-L2280 | [
"def",
"get_json_object",
"(",
"col",
",",
"path",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"get_json_object",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"path",
")",
"return... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | json_tuple | 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"))
... | python/pyspark/sql/functions.py | 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):
"""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... | [
"Creates",
"a",
"new",
"row",
"for",
"a",
"json",
"column",
"according",
"to",
"the",
"given",
"field",
"names",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2285-L2298 | [
"def",
"json_tuple",
"(",
"col",
",",
"*",
"fields",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"json_tuple",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"_to_seq",
"(",
"sc",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | from_json | Parses a column containing a JSON string into a :class:`MapType` with :class:`StringType`
as keys type, :class:`StructType` or :class:`ArrayType` with
the specified schema. Returns `null`, in the case of an unparseable string.
:param col: string column in json format
:param schema: a StructType or Arra... | python/pyspark/sql/functions.py | def from_json(col, schema, options={}):
"""
Parses a column containing a JSON string into a :class:`MapType` with :class:`StringType`
as keys type, :class:`StructType` or :class:`ArrayType` with
the specified schema. Returns `null`, in the case of an unparseable string.
:param col: string column in... | def from_json(col, schema, options={}):
"""
Parses a column containing a JSON string into a :class:`MapType` with :class:`StringType`
as keys type, :class:`StructType` or :class:`ArrayType` with
the specified schema. Returns `null`, in the case of an unparseable string.
:param col: string column in... | [
"Parses",
"a",
"column",
"containing",
"a",
"JSON",
"string",
"into",
"a",
":",
"class",
":",
"MapType",
"with",
":",
"class",
":",
"StringType",
"as",
"keys",
"type",
":",
"class",
":",
"StructType",
"or",
":",
"class",
":",
"ArrayType",
"with",
"the",
... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2303-L2347 | [
"def",
"from_json",
"(",
"col",
",",
"schema",
",",
"options",
"=",
"{",
"}",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"isinstance",
"(",
"schema",
",",
"DataType",
")",
":",
"schema",
"=",
"schema",
".",
"json",
"(",
")... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | schema_of_json | 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... | python/pyspark/sql/functions.py | 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={}):
"""
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... | [
"Parses",
"a",
"JSON",
"string",
"and",
"infers",
"its",
"schema",
"in",
"DDL",
"format",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2393-L2419 | [
"def",
"schema_of_json",
"(",
"json",
",",
"options",
"=",
"{",
"}",
")",
":",
"if",
"isinstance",
"(",
"json",
",",
"basestring",
")",
":",
"col",
"=",
"_create_column_from_literal",
"(",
"json",
")",
"elif",
"isinstance",
"(",
"json",
",",
"Column",
")... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | schema_of_csv | 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("... | python/pyspark/sql/functions.py | 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={}):
"""
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... | [
"Parses",
"a",
"CSV",
"string",
"and",
"infers",
"its",
"schema",
"in",
"DDL",
"format",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2424-L2446 | [
"def",
"schema_of_csv",
"(",
"csv",
",",
"options",
"=",
"{",
"}",
")",
":",
"if",
"isinstance",
"(",
"csv",
",",
"basestring",
")",
":",
"col",
"=",
"_create_column_from_literal",
"(",
"csv",
")",
"elif",
"isinstance",
"(",
"csv",
",",
"Column",
")",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | to_csv | Converts a column containing a :class:`StructType` into a CSV string.
Throws an exception, in the case of an unsupported type.
:param col: name of column containing a struct.
:param options: options to control converting. accepts the same options as the CSV datasource.
>>> from pyspark.sql import Row
... | python/pyspark/sql/functions.py | def to_csv(col, options={}):
"""
Converts a column containing a :class:`StructType` into a CSV string.
Throws an exception, in the case of an unsupported type.
:param col: name of column containing a struct.
:param options: options to control converting. accepts the same options as the CSV datasour... | def to_csv(col, options={}):
"""
Converts a column containing a :class:`StructType` into a CSV string.
Throws an exception, in the case of an unsupported type.
:param col: name of column containing a struct.
:param options: options to control converting. accepts the same options as the CSV datasour... | [
"Converts",
"a",
"column",
"containing",
"a",
":",
"class",
":",
"StructType",
"into",
"a",
"CSV",
"string",
".",
"Throws",
"an",
"exception",
"in",
"the",
"case",
"of",
"an",
"unsupported",
"type",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2451-L2468 | [
"def",
"to_csv",
"(",
"col",
",",
"options",
"=",
"{",
"}",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"to_csv",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"options",
")",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | size | Collection function: returns the length of the array or map stored in the column.
:param col: name of column or expression
>>> df = spark.createDataFrame([([1, 2, 3],),([1],),([],)], ['data'])
>>> df.select(size(df.data)).collect()
[Row(size(data)=3), Row(size(data)=1), Row(size(data)=0)] | python/pyspark/sql/functions.py | def size(col):
"""
Collection function: returns the length of the array or map stored in the column.
:param col: name of column or expression
>>> df = spark.createDataFrame([([1, 2, 3],),([1],),([],)], ['data'])
>>> df.select(size(df.data)).collect()
[Row(size(data)=3), Row(size(data)=1), Row(... | def size(col):
"""
Collection function: returns the length of the array or map stored in the column.
:param col: name of column or expression
>>> df = spark.createDataFrame([([1, 2, 3],),([1],),([],)], ['data'])
>>> df.select(size(df.data)).collect()
[Row(size(data)=3), Row(size(data)=1), Row(... | [
"Collection",
"function",
":",
"returns",
"the",
"length",
"of",
"the",
"array",
"or",
"map",
"stored",
"in",
"the",
"column",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2472-L2483 | [
"def",
"size",
"(",
"col",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"size",
"(",
"_to_java_column",
"(",
"col",
")",
")",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | sort_array | Collection function: sorts the input array in ascending or descending order according
to the natural ordering of the array elements. Null elements will be placed at the beginning
of the returned array in ascending order or at the end of the returned array in descending
order.
:param col: name of column... | python/pyspark/sql/functions.py | def sort_array(col, asc=True):
"""
Collection function: sorts the input array in ascending or descending order according
to the natural ordering of the array elements. Null elements will be placed at the beginning
of the returned array in ascending order or at the end of the returned array in descending... | def sort_array(col, asc=True):
"""
Collection function: sorts the input array in ascending or descending order according
to the natural ordering of the array elements. Null elements will be placed at the beginning
of the returned array in ascending order or at the end of the returned array in descending... | [
"Collection",
"function",
":",
"sorts",
"the",
"input",
"array",
"in",
"ascending",
"or",
"descending",
"order",
"according",
"to",
"the",
"natural",
"ordering",
"of",
"the",
"array",
"elements",
".",
"Null",
"elements",
"will",
"be",
"placed",
"at",
"the",
... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2517-L2533 | [
"def",
"sort_array",
"(",
"col",
",",
"asc",
"=",
"True",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"sort_array",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"a... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | array_repeat | Collection function: creates an array containing a column repeated count times.
>>> df = spark.createDataFrame([('ab',)], ['data'])
>>> df.select(array_repeat(df.data, 3).alias('r')).collect()
[Row(r=[u'ab', u'ab', u'ab'])] | python/pyspark/sql/functions.py | def array_repeat(col, count):
"""
Collection function: creates an array containing a column repeated count times.
>>> df = spark.createDataFrame([('ab',)], ['data'])
>>> df.select(array_repeat(df.data, 3).alias('r')).collect()
[Row(r=[u'ab', u'ab', u'ab'])]
"""
sc = SparkContext._active_spa... | def array_repeat(col, count):
"""
Collection function: creates an array containing a column repeated count times.
>>> df = spark.createDataFrame([('ab',)], ['data'])
>>> df.select(array_repeat(df.data, 3).alias('r')).collect()
[Row(r=[u'ab', u'ab', u'ab'])]
"""
sc = SparkContext._active_spa... | [
"Collection",
"function",
":",
"creates",
"an",
"array",
"containing",
"a",
"column",
"repeated",
"count",
"times",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2687-L2696 | [
"def",
"array_repeat",
"(",
"col",
",",
"count",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"array_repeat",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"count",
")... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | map_concat | 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... | python/pyspark/sql/functions.py | 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):
"""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(... | [
"Returns",
"the",
"union",
"of",
"all",
"the",
"given",
"maps",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2717-L2735 | [
"def",
"map_concat",
"(",
"*",
"cols",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"len",
"(",
"cols",
")",
"==",
"1",
"and",
"isinstance",
"(",
"cols",
"[",
"0",
"]",
",",
"(",
"list",
",",
"set",
")",
")",
":",
"cols"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | sequence | Generate a sequence of integers from `start` to `stop`, incrementing by `step`.
If `step` is not set, incrementing by 1 if `start` is less than or equal to `stop`,
otherwise -1.
>>> df1 = spark.createDataFrame([(-2, 2)], ('C1', 'C2'))
>>> df1.select(sequence('C1', 'C2').alias('r')).collect()
[Row(r... | python/pyspark/sql/functions.py | def sequence(start, stop, step=None):
"""
Generate a sequence of integers from `start` to `stop`, incrementing by `step`.
If `step` is not set, incrementing by 1 if `start` is less than or equal to `stop`,
otherwise -1.
>>> df1 = spark.createDataFrame([(-2, 2)], ('C1', 'C2'))
>>> df1.select(seq... | def sequence(start, stop, step=None):
"""
Generate a sequence of integers from `start` to `stop`, incrementing by `step`.
If `step` is not set, incrementing by 1 if `start` is less than or equal to `stop`,
otherwise -1.
>>> df1 = spark.createDataFrame([(-2, 2)], ('C1', 'C2'))
>>> df1.select(seq... | [
"Generate",
"a",
"sequence",
"of",
"integers",
"from",
"start",
"to",
"stop",
"incrementing",
"by",
"step",
".",
"If",
"step",
"is",
"not",
"set",
"incrementing",
"by",
"1",
"if",
"start",
"is",
"less",
"than",
"or",
"equal",
"to",
"stop",
"otherwise",
"... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2739-L2757 | [
"def",
"sequence",
"(",
"start",
",",
"stop",
",",
"step",
"=",
"None",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"step",
"is",
"None",
":",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"sequence",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | from_csv | Parses a column containing a CSV string to a row with the specified schema.
Returns `null`, in the case of an unparseable string.
:param col: string column in CSV format
:param schema: a string with schema in DDL format to use when parsing the CSV column.
:param options: options to control parsing. acc... | python/pyspark/sql/functions.py | def from_csv(col, schema, options={}):
"""
Parses a column containing a CSV string to a row with the specified schema.
Returns `null`, in the case of an unparseable string.
:param col: string column in CSV format
:param schema: a string with schema in DDL format to use when parsing the CSV column.
... | def from_csv(col, schema, options={}):
"""
Parses a column containing a CSV string to a row with the specified schema.
Returns `null`, in the case of an unparseable string.
:param col: string column in CSV format
:param schema: a string with schema in DDL format to use when parsing the CSV column.
... | [
"Parses",
"a",
"column",
"containing",
"a",
"CSV",
"string",
"to",
"a",
"row",
"with",
"the",
"specified",
"schema",
".",
"Returns",
"null",
"in",
"the",
"case",
"of",
"an",
"unparseable",
"string",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2762-L2789 | [
"def",
"from_csv",
"(",
"col",
",",
"schema",
",",
"options",
"=",
"{",
"}",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"isinstance",
"(",
"schema",
",",
"basestring",
")",
":",
"schema",
"=",
"_create_column_from_literal",
"(",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | udf | Creates a user defined function (UDF).
.. note:: The user-defined functions are considered deterministic by default. Due to
optimization, duplicate invocations may be eliminated or the function may even be invoked
more times than it is present in the query. If your function is not deterministic, ca... | python/pyspark/sql/functions.py | def udf(f=None, returnType=StringType()):
"""Creates a user defined function (UDF).
.. note:: The user-defined functions are considered deterministic by default. Due to
optimization, duplicate invocations may be eliminated or the function may even be invoked
more times than it is present in the... | def udf(f=None, returnType=StringType()):
"""Creates a user defined function (UDF).
.. note:: The user-defined functions are considered deterministic by default. Due to
optimization, duplicate invocations may be eliminated or the function may even be invoked
more times than it is present in the... | [
"Creates",
"a",
"user",
"defined",
"function",
"(",
"UDF",
")",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2805-L2889 | [
"def",
"udf",
"(",
"f",
"=",
"None",
",",
"returnType",
"=",
"StringType",
"(",
")",
")",
":",
"# The following table shows most of Python data and SQL type conversions in normal UDFs that",
"# are not yet visible to the user. Some of behaviors are buggy and might be changed in the nea... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | pandas_udf | Creates a vectorized user defined function (UDF).
:param f: user-defined function. A python function if used as a standalone function
:param returnType: the return type of the user-defined function. The value can be either a
:class:`pyspark.sql.types.DataType` object or a DDL-formatted type string.
... | python/pyspark/sql/functions.py | def pandas_udf(f=None, returnType=None, functionType=None):
"""
Creates a vectorized user defined function (UDF).
:param f: user-defined function. A python function if used as a standalone function
:param returnType: the return type of the user-defined function. The value can be either a
:class... | def pandas_udf(f=None, returnType=None, functionType=None):
"""
Creates a vectorized user defined function (UDF).
:param f: user-defined function. A python function if used as a standalone function
:param returnType: the return type of the user-defined function. The value can be either a
:class... | [
"Creates",
"a",
"vectorized",
"user",
"defined",
"function",
"(",
"UDF",
")",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2893-L3189 | [
"def",
"pandas_udf",
"(",
"f",
"=",
"None",
",",
"returnType",
"=",
"None",
",",
"functionType",
"=",
"None",
")",
":",
"# The following table shows most of Pandas data and SQL type conversions in Pandas UDFs that",
"# are not yet visible to the user. Some of behaviors are buggy an... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | to_str | A wrapper over str(), but converts bool values to lower case strings.
If None is given, just returns None, instead of converting it to string "None". | python/pyspark/sql/readwriter.py | def to_str(value):
"""
A wrapper over str(), but converts bool values to lower case strings.
If None is given, just returns None, instead of converting it to string "None".
"""
if isinstance(value, bool):
return str(value).lower()
elif value is None:
return value
else:
... | def to_str(value):
"""
A wrapper over str(), but converts bool values to lower case strings.
If None is given, just returns None, instead of converting it to string "None".
"""
if isinstance(value, bool):
return str(value).lower()
elif value is None:
return value
else:
... | [
"A",
"wrapper",
"over",
"str",
"()",
"but",
"converts",
"bool",
"values",
"to",
"lower",
"case",
"strings",
".",
"If",
"None",
"is",
"given",
"just",
"returns",
"None",
"instead",
"of",
"converting",
"it",
"to",
"string",
"None",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L34-L44 | [
"def",
"to_str",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"bool",
")",
":",
"return",
"str",
"(",
"value",
")",
".",
"lower",
"(",
")",
"elif",
"value",
"is",
"None",
":",
"return",
"value",
"else",
":",
"return",
"str",
"(",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | OptionUtils._set_opts | Set named options (filter out those the value is None) | python/pyspark/sql/readwriter.py | def _set_opts(self, schema=None, **options):
"""
Set named options (filter out those the value is None)
"""
if schema is not None:
self.schema(schema)
for k, v in options.items():
if v is not None:
self.option(k, v) | def _set_opts(self, schema=None, **options):
"""
Set named options (filter out those the value is None)
"""
if schema is not None:
self.schema(schema)
for k, v in options.items():
if v is not None:
self.option(k, v) | [
"Set",
"named",
"options",
"(",
"filter",
"out",
"those",
"the",
"value",
"is",
"None",
")"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L49-L57 | [
"def",
"_set_opts",
"(",
"self",
",",
"schema",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"if",
"schema",
"is",
"not",
"None",
":",
"self",
".",
"schema",
"(",
"schema",
")",
"for",
"k",
",",
"v",
"in",
"options",
".",
"items",
"(",
")",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameReader.format | Specifies the input data source format.
:param source: string, name of the data source, e.g. 'json', 'parquet'.
>>> df = spark.read.format('json').load('python/test_support/sql/people.json')
>>> df.dtypes
[('age', 'bigint'), ('name', 'string')] | python/pyspark/sql/readwriter.py | def format(self, source):
"""Specifies the input data source format.
:param source: string, name of the data source, e.g. 'json', 'parquet'.
>>> df = spark.read.format('json').load('python/test_support/sql/people.json')
>>> df.dtypes
[('age', 'bigint'), ('name', 'string')]
... | def format(self, source):
"""Specifies the input data source format.
:param source: string, name of the data source, e.g. 'json', 'parquet'.
>>> df = spark.read.format('json').load('python/test_support/sql/people.json')
>>> df.dtypes
[('age', 'bigint'), ('name', 'string')]
... | [
"Specifies",
"the",
"input",
"data",
"source",
"format",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L78-L89 | [
"def",
"format",
"(",
"self",
",",
"source",
")",
":",
"self",
".",
"_jreader",
"=",
"self",
".",
"_jreader",
".",
"format",
"(",
"source",
")",
"return",
"self"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameReader.schema | Specifies the input schema.
Some data sources (e.g. JSON) can infer the input schema automatically from data.
By specifying the schema here, the underlying data source can skip the schema
inference step, and thus speed up data loading.
:param schema: a :class:`pyspark.sql.types.StructT... | python/pyspark/sql/readwriter.py | def schema(self, schema):
"""Specifies the input schema.
Some data sources (e.g. JSON) can infer the input schema automatically from data.
By specifying the schema here, the underlying data source can skip the schema
inference step, and thus speed up data loading.
:param schema... | def schema(self, schema):
"""Specifies the input schema.
Some data sources (e.g. JSON) can infer the input schema automatically from data.
By specifying the schema here, the underlying data source can skip the schema
inference step, and thus speed up data loading.
:param schema... | [
"Specifies",
"the",
"input",
"schema",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L92-L113 | [
"def",
"schema",
"(",
"self",
",",
"schema",
")",
":",
"from",
"pyspark",
".",
"sql",
"import",
"SparkSession",
"spark",
"=",
"SparkSession",
".",
"builder",
".",
"getOrCreate",
"(",
")",
"if",
"isinstance",
"(",
"schema",
",",
"StructType",
")",
":",
"j... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameReader.option | Adds an input option for the underlying data source.
You can set the following option(s) for reading files:
* ``timeZone``: sets the string that indicates a timezone to be used to parse timestamps
in the JSON/CSV datasources or partition values.
If it isn't set, it u... | python/pyspark/sql/readwriter.py | def option(self, key, value):
"""Adds an input option for the underlying data source.
You can set the following option(s) for reading files:
* ``timeZone``: sets the string that indicates a timezone to be used to parse timestamps
in the JSON/CSV datasources or partition valu... | def option(self, key, value):
"""Adds an input option for the underlying data source.
You can set the following option(s) for reading files:
* ``timeZone``: sets the string that indicates a timezone to be used to parse timestamps
in the JSON/CSV datasources or partition valu... | [
"Adds",
"an",
"input",
"option",
"for",
"the",
"underlying",
"data",
"source",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L116-L125 | [
"def",
"option",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"_jreader",
"=",
"self",
".",
"_jreader",
".",
"option",
"(",
"key",
",",
"to_str",
"(",
"value",
")",
")",
"return",
"self"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameReader.options | Adds input options for the underlying data source.
You can set the following option(s) for reading files:
* ``timeZone``: sets the string that indicates a timezone to be used to parse timestamps
in the JSON/CSV datasources or partition values.
If it isn't set, it use... | python/pyspark/sql/readwriter.py | def options(self, **options):
"""Adds input options for the underlying data source.
You can set the following option(s) for reading files:
* ``timeZone``: sets the string that indicates a timezone to be used to parse timestamps
in the JSON/CSV datasources or partition values... | def options(self, **options):
"""Adds input options for the underlying data source.
You can set the following option(s) for reading files:
* ``timeZone``: sets the string that indicates a timezone to be used to parse timestamps
in the JSON/CSV datasources or partition values... | [
"Adds",
"input",
"options",
"for",
"the",
"underlying",
"data",
"source",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L128-L138 | [
"def",
"options",
"(",
"self",
",",
"*",
"*",
"options",
")",
":",
"for",
"k",
"in",
"options",
":",
"self",
".",
"_jreader",
"=",
"self",
".",
"_jreader",
".",
"option",
"(",
"k",
",",
"to_str",
"(",
"options",
"[",
"k",
"]",
")",
")",
"return",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameReader.load | Loads data from a data source and returns it as a :class`DataFrame`.
:param path: optional string or a list of string for file-system backed data sources.
:param format: optional string for format of the data source. Default to 'parquet'.
:param schema: optional :class:`pyspark.sql.types.Struct... | python/pyspark/sql/readwriter.py | def load(self, path=None, format=None, schema=None, **options):
"""Loads data from a data source and returns it as a :class`DataFrame`.
:param path: optional string or a list of string for file-system backed data sources.
:param format: optional string for format of the data source. Default to ... | def load(self, path=None, format=None, schema=None, **options):
"""Loads data from a data source and returns it as a :class`DataFrame`.
:param path: optional string or a list of string for file-system backed data sources.
:param format: optional string for format of the data source. Default to ... | [
"Loads",
"data",
"from",
"a",
"data",
"source",
"and",
"returns",
"it",
"as",
"a",
":",
"class",
"DataFrame",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L141-L172 | [
"def",
"load",
"(",
"self",
",",
"path",
"=",
"None",
",",
"format",
"=",
"None",
",",
"schema",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"if",
"format",
"is",
"not",
"None",
":",
"self",
".",
"format",
"(",
"format",
")",
"if",
"schema",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameReader.json | Loads JSON files and returns the results as a :class:`DataFrame`.
`JSON Lines <http://jsonlines.org/>`_ (newline-delimited JSON) is supported by default.
For JSON (one record per file), set the ``multiLine`` parameter to ``true``.
If the ``schema`` parameter is not specified, this function goe... | python/pyspark/sql/readwriter.py | def json(self, path, schema=None, primitivesAsString=None, prefersDecimal=None,
allowComments=None, allowUnquotedFieldNames=None, allowSingleQuotes=None,
allowNumericLeadingZero=None, allowBackslashEscapingAnyCharacter=None,
mode=None, columnNameOfCorruptRecord=None, dateFormat=No... | def json(self, path, schema=None, primitivesAsString=None, prefersDecimal=None,
allowComments=None, allowUnquotedFieldNames=None, allowSingleQuotes=None,
allowNumericLeadingZero=None, allowBackslashEscapingAnyCharacter=None,
mode=None, columnNameOfCorruptRecord=None, dateFormat=No... | [
"Loads",
"JSON",
"files",
"and",
"returns",
"the",
"results",
"as",
"a",
":",
"class",
":",
"DataFrame",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L175-L293 | [
"def",
"json",
"(",
"self",
",",
"path",
",",
"schema",
"=",
"None",
",",
"primitivesAsString",
"=",
"None",
",",
"prefersDecimal",
"=",
"None",
",",
"allowComments",
"=",
"None",
",",
"allowUnquotedFieldNames",
"=",
"None",
",",
"allowSingleQuotes",
"=",
"N... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameReader.parquet | Loads Parquet files, returning the result as a :class:`DataFrame`.
You can set the following Parquet-specific option(s) for reading Parquet files:
* ``mergeSchema``: sets whether we should merge schemas collected from all \
Parquet part-files. This will override ``spark.sql.parquet.... | python/pyspark/sql/readwriter.py | def parquet(self, *paths):
"""Loads Parquet files, returning the result as a :class:`DataFrame`.
You can set the following Parquet-specific option(s) for reading Parquet files:
* ``mergeSchema``: sets whether we should merge schemas collected from all \
Parquet part-files. T... | def parquet(self, *paths):
"""Loads Parquet files, returning the result as a :class:`DataFrame`.
You can set the following Parquet-specific option(s) for reading Parquet files:
* ``mergeSchema``: sets whether we should merge schemas collected from all \
Parquet part-files. T... | [
"Loads",
"Parquet",
"files",
"returning",
"the",
"result",
"as",
"a",
":",
"class",
":",
"DataFrame",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L309-L321 | [
"def",
"parquet",
"(",
"self",
",",
"*",
"paths",
")",
":",
"return",
"self",
".",
"_df",
"(",
"self",
".",
"_jreader",
".",
"parquet",
"(",
"_to_seq",
"(",
"self",
".",
"_spark",
".",
"_sc",
",",
"paths",
")",
")",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameReader.text | Loads text files and returns a :class:`DataFrame` whose schema starts with a
string column named "value", and followed by partitioned columns if there
are any.
The text files must be encoded as UTF-8.
By default, each line in the text file is a new row in the resulting DataFrame.
... | python/pyspark/sql/readwriter.py | def text(self, paths, wholetext=False, lineSep=None):
"""
Loads text files and returns a :class:`DataFrame` whose schema starts with a
string column named "value", and followed by partitioned columns if there
are any.
The text files must be encoded as UTF-8.
By default, ... | def text(self, paths, wholetext=False, lineSep=None):
"""
Loads text files and returns a :class:`DataFrame` whose schema starts with a
string column named "value", and followed by partitioned columns if there
are any.
The text files must be encoded as UTF-8.
By default, ... | [
"Loads",
"text",
"files",
"and",
"returns",
"a",
":",
"class",
":",
"DataFrame",
"whose",
"schema",
"starts",
"with",
"a",
"string",
"column",
"named",
"value",
"and",
"followed",
"by",
"partitioned",
"columns",
"if",
"there",
"are",
"any",
".",
"The",
"te... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L325-L349 | [
"def",
"text",
"(",
"self",
",",
"paths",
",",
"wholetext",
"=",
"False",
",",
"lineSep",
"=",
"None",
")",
":",
"self",
".",
"_set_opts",
"(",
"wholetext",
"=",
"wholetext",
",",
"lineSep",
"=",
"lineSep",
")",
"if",
"isinstance",
"(",
"paths",
",",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameReader.csv | r"""Loads a CSV file and returns the result as a :class:`DataFrame`.
This function will go through the input once to determine the input schema if
``inferSchema`` is enabled. To avoid going through the entire data once, disable
``inferSchema`` option or specify the schema explicitly using ``sc... | python/pyspark/sql/readwriter.py | def csv(self, path, schema=None, sep=None, encoding=None, quote=None, escape=None,
comment=None, header=None, inferSchema=None, ignoreLeadingWhiteSpace=None,
ignoreTrailingWhiteSpace=None, nullValue=None, nanValue=None, positiveInf=None,
negativeInf=None, dateFormat=None, timestampFo... | def csv(self, path, schema=None, sep=None, encoding=None, quote=None, escape=None,
comment=None, header=None, inferSchema=None, ignoreLeadingWhiteSpace=None,
ignoreTrailingWhiteSpace=None, nullValue=None, nanValue=None, positiveInf=None,
negativeInf=None, dateFormat=None, timestampFo... | [
"r",
"Loads",
"a",
"CSV",
"file",
"and",
"returns",
"the",
"result",
"as",
"a",
":",
"class",
":",
"DataFrame",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L352-L506 | [
"def",
"csv",
"(",
"self",
",",
"path",
",",
"schema",
"=",
"None",
",",
"sep",
"=",
"None",
",",
"encoding",
"=",
"None",
",",
"quote",
"=",
"None",
",",
"escape",
"=",
"None",
",",
"comment",
"=",
"None",
",",
"header",
"=",
"None",
",",
"infer... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameReader.orc | Loads ORC files, returning the result as a :class:`DataFrame`.
>>> df = spark.read.orc('python/test_support/sql/orc_partitioned')
>>> df.dtypes
[('a', 'bigint'), ('b', 'int'), ('c', 'int')] | python/pyspark/sql/readwriter.py | def orc(self, path):
"""Loads ORC files, returning the result as a :class:`DataFrame`.
>>> df = spark.read.orc('python/test_support/sql/orc_partitioned')
>>> df.dtypes
[('a', 'bigint'), ('b', 'int'), ('c', 'int')]
"""
if isinstance(path, basestring):
path = [... | def orc(self, path):
"""Loads ORC files, returning the result as a :class:`DataFrame`.
>>> df = spark.read.orc('python/test_support/sql/orc_partitioned')
>>> df.dtypes
[('a', 'bigint'), ('b', 'int'), ('c', 'int')]
"""
if isinstance(path, basestring):
path = [... | [
"Loads",
"ORC",
"files",
"returning",
"the",
"result",
"as",
"a",
":",
"class",
":",
"DataFrame",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L509-L518 | [
"def",
"orc",
"(",
"self",
",",
"path",
")",
":",
"if",
"isinstance",
"(",
"path",
",",
"basestring",
")",
":",
"path",
"=",
"[",
"path",
"]",
"return",
"self",
".",
"_df",
"(",
"self",
".",
"_jreader",
".",
"orc",
"(",
"_to_seq",
"(",
"self",
".... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameReader.jdbc | Construct a :class:`DataFrame` representing the database table named ``table``
accessible via JDBC URL ``url`` and connection ``properties``.
Partitions of the table will be retrieved in parallel if either ``column`` or
``predicates`` is specified. ``lowerBound`, ``upperBound`` and ``numPartiti... | python/pyspark/sql/readwriter.py | def jdbc(self, url, table, column=None, lowerBound=None, upperBound=None, numPartitions=None,
predicates=None, properties=None):
"""
Construct a :class:`DataFrame` representing the database table named ``table``
accessible via JDBC URL ``url`` and connection ``properties``.
... | def jdbc(self, url, table, column=None, lowerBound=None, upperBound=None, numPartitions=None,
predicates=None, properties=None):
"""
Construct a :class:`DataFrame` representing the database table named ``table``
accessible via JDBC URL ``url`` and connection ``properties``.
... | [
"Construct",
"a",
":",
"class",
":",
"DataFrame",
"representing",
"the",
"database",
"table",
"named",
"table",
"accessible",
"via",
"JDBC",
"URL",
"url",
"and",
"connection",
"properties",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L521-L569 | [
"def",
"jdbc",
"(",
"self",
",",
"url",
",",
"table",
",",
"column",
"=",
"None",
",",
"lowerBound",
"=",
"None",
",",
"upperBound",
"=",
"None",
",",
"numPartitions",
"=",
"None",
",",
"predicates",
"=",
"None",
",",
"properties",
"=",
"None",
")",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameWriter.mode | Specifies the behavior when data or table already exists.
Options include:
* `append`: Append contents of this :class:`DataFrame` to existing data.
* `overwrite`: Overwrite existing data.
* `error` or `errorifexists`: Throw an exception if data already exists.
* `ignore`: Silen... | python/pyspark/sql/readwriter.py | def mode(self, saveMode):
"""Specifies the behavior when data or table already exists.
Options include:
* `append`: Append contents of this :class:`DataFrame` to existing data.
* `overwrite`: Overwrite existing data.
* `error` or `errorifexists`: Throw an exception if data alre... | def mode(self, saveMode):
"""Specifies the behavior when data or table already exists.
Options include:
* `append`: Append contents of this :class:`DataFrame` to existing data.
* `overwrite`: Overwrite existing data.
* `error` or `errorifexists`: Throw an exception if data alre... | [
"Specifies",
"the",
"behavior",
"when",
"data",
"or",
"table",
"already",
"exists",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L590-L606 | [
"def",
"mode",
"(",
"self",
",",
"saveMode",
")",
":",
"# At the JVM side, the default value of mode is already set to \"error\".",
"# So, if the given saveMode is None, we will not call JVM-side's mode method.",
"if",
"saveMode",
"is",
"not",
"None",
":",
"self",
".",
"_jwrite",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameWriter.format | Specifies the underlying output data source.
:param source: string, name of the data source, e.g. 'json', 'parquet'.
>>> df.write.format('json').save(os.path.join(tempfile.mkdtemp(), 'data')) | python/pyspark/sql/readwriter.py | def format(self, source):
"""Specifies the underlying output data source.
:param source: string, name of the data source, e.g. 'json', 'parquet'.
>>> df.write.format('json').save(os.path.join(tempfile.mkdtemp(), 'data'))
"""
self._jwrite = self._jwrite.format(source)
re... | def format(self, source):
"""Specifies the underlying output data source.
:param source: string, name of the data source, e.g. 'json', 'parquet'.
>>> df.write.format('json').save(os.path.join(tempfile.mkdtemp(), 'data'))
"""
self._jwrite = self._jwrite.format(source)
re... | [
"Specifies",
"the",
"underlying",
"output",
"data",
"source",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L609-L617 | [
"def",
"format",
"(",
"self",
",",
"source",
")",
":",
"self",
".",
"_jwrite",
"=",
"self",
".",
"_jwrite",
".",
"format",
"(",
"source",
")",
"return",
"self"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameWriter.option | Adds an output option for the underlying data source.
You can set the following option(s) for writing files:
* ``timeZone``: sets the string that indicates a timezone to be used to format
timestamps in the JSON/CSV datasources or partition values.
If it isn't set, it... | python/pyspark/sql/readwriter.py | def option(self, key, value):
"""Adds an output option for the underlying data source.
You can set the following option(s) for writing files:
* ``timeZone``: sets the string that indicates a timezone to be used to format
timestamps in the JSON/CSV datasources or partition va... | def option(self, key, value):
"""Adds an output option for the underlying data source.
You can set the following option(s) for writing files:
* ``timeZone``: sets the string that indicates a timezone to be used to format
timestamps in the JSON/CSV datasources or partition va... | [
"Adds",
"an",
"output",
"option",
"for",
"the",
"underlying",
"data",
"source",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L620-L629 | [
"def",
"option",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"_jwrite",
"=",
"self",
".",
"_jwrite",
".",
"option",
"(",
"key",
",",
"to_str",
"(",
"value",
")",
")",
"return",
"self"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.