HyukjinKwon commented on code in PR #37592:
URL: https://github.com/apache/spark/pull/37592#discussion_r952037018
##########
python/pyspark/sql/functions.py:
##########
@@ -994,12 +1007,19 @@ def cot(col: "ColumnOrName") -> Column:
Parameters
----------
col : :class:`~pyspark.sql.Column` or str
- Angle in radians
+ angle in radians.
Returns
-------
:class:`~pyspark.sql.Column`
- Cotangent of the angle.
+ cotangent of the angle.
+
+ Examples
+ --------
+ >>> import math
+ >>> df = spark.range(1)
+ >>> df.select(cot(lit(math.radians(45)))).first() # doctest: +ELLIPSIS
Review Comment:
```suggestion
>>> df.select(cot(lit(math.radians(45)))).first()
```
##########
python/pyspark/sql/functions.py:
##########
@@ -962,6 +962,13 @@ def cos(col: "ColumnOrName") -> Column:
-------
:class:`~pyspark.sql.Column`
cosine of the angle, as if computed by `java.lang.Math.cos()`.
+
+ Examples
+ --------
+ >>> import math
+ >>> df = spark.range(1)
+ >>> df.select(cos(lit(math.pi))).first() # doctest: +ELLIPSIS
Review Comment:
```suggestion
>>> df.select(cos(lit(math.pi))).first()
```
##########
python/pyspark/sql/functions.py:
##########
@@ -1055,6 +1138,23 @@ def log(col: "ColumnOrName") -> Column:
Computes the natural logarithm of the given value.
.. versionadded:: 1.4.0
+
+ Parameters
+ ----------
+ col : :class:`~pyspark.sql.Column` or str
+ column to calculate natural logarithm for.
+
+ Returns
+ -------
+ :class:`~pyspark.sql.Column`
+ natural logarithm of the given value.
+
+ Examples
+ --------
+ >>> import math
+ >>> df = spark.range(1)
+ >>> df.select(log(lit(math.e))).first() # doctest: +ELLIPSIS
Review Comment:
```suggestion
>>> df.select(log(lit(math.e))).first()
```
##########
python/pyspark/sql/functions.py:
##########
@@ -1142,13 +1352,19 @@ def sinh(col: "ColumnOrName") -> Column:
Parameters
----------
col : :class:`~pyspark.sql.Column` or str
- hyperbolic angle
+ hyperbolic angle.
Returns
-------
:class:`~pyspark.sql.Column`
hyperbolic sine of the given value,
as if computed by `java.lang.Math.sinh()`
+
+ Examples
+ --------
+ >>> df = spark.range(1)
+ >>> df.select(sinh(lit(1.1))).first() # doctest: +ELLIPSIS
Review Comment:
```suggestion
>>> df.select(sinh(lit(1.1))).first()
```
##########
python/pyspark/sql/functions.py:
##########
@@ -1064,15 +1164,57 @@ def log10(col: "ColumnOrName") -> Column:
Computes the logarithm of the given value in Base 10.
.. versionadded:: 1.4.0
+
+ Parameters
+ ----------
+ col : :class:`~pyspark.sql.Column` or str
+ column to calculate logarithm for.
+
+ Returns
+ -------
+ :class:`~pyspark.sql.Column`
+ logarithm of the given value in Base 10.
+
+ Examples
+ --------
+ >>> df = spark.range(1)
+ >>> df.select(log10(lit(100))).show()
+ +----------+
+ |LOG10(100)|
+ +----------+
+ | 2.0|
+ +----------+
"""
return _invoke_function_over_columns("log10", col)
def log1p(col: "ColumnOrName") -> Column:
"""
- Computes the natural logarithm of the given value plus one.
+ Computes the natural logarithm of the "given value plus one".
.. versionadded:: 1.4.0
+
+ Parameters
+ ----------
+ col : :class:`~pyspark.sql.Column` or str
+ column to calculate natural logarithm for.
+
+ Returns
+ -------
+ :class:`~pyspark.sql.Column`
+ natural logarithm of the "given value plus one".
+
+ Examples
+ --------
+ >>> import math
+ >>> df = spark.range(1)
+ >>> df.select(log1p(lit(math.e))).first() # doctest: +ELLIPSIS
Review Comment:
```suggestion
>>> df.select(log1p(lit(math.e))).first()
```
##########
python/pyspark/sql/functions.py:
##########
@@ -1305,6 +1677,22 @@ def stddev_samp(col: "ColumnOrName") -> Column:
the expression in a group.
.. versionadded:: 1.6.0
+
+ Parameters
+ ----------
+ col : :class:`~pyspark.sql.Column` or str
+ target column to compute on.
+
+ Returns
+ -------
+ :class:`~pyspark.sql.Column`
+ standard deviation of given column.
+
+ Examples
+ --------
+ >>> df = spark.range(6)
+ >>> df.select(stddev_samp(df.id)).first() # doctest: +ELLIPSIS
Review Comment:
```suggestion
>>> df.select(stddev_samp(df.id)).first()
```
##########
python/pyspark/sql/functions.py:
##########
@@ -1315,6 +1703,22 @@ def stddev_pop(col: "ColumnOrName") -> Column:
the expression in a group.
.. versionadded:: 1.6.0
+
+ Parameters
+ ----------
+ col : :class:`~pyspark.sql.Column` or str
+ target column to compute on.
+
+ Returns
+ -------
+ :class:`~pyspark.sql.Column`
+ standard deviation of given column.
+
+ Examples
+ --------
+ >>> df = spark.range(6)
+ >>> df.select(stddev_pop(df.id)).first() # doctest: +ELLIPSIS
Review Comment:
```suggestion
>>> df.select(stddev_pop(df.id)).first()
```
##########
python/pyspark/sql/functions.py:
##########
@@ -1343,6 +1787,22 @@ def var_pop(col: "ColumnOrName") -> Column:
Aggregate function: returns the population variance of the values in a
group.
.. versionadded:: 1.6.0
+
+ Parameters
+ ----------
+ col : :class:`~pyspark.sql.Column` or str
+ target column to compute on.
+
+ Returns
+ -------
+ :class:`~pyspark.sql.Column`
+ variance of given column.
+
+ Examples
+ --------
+ >>> df = spark.range(6)
+ >>> df.select(var_pop(df.id)).first() # doctest: +ELLIPSIS
Review Comment:
```suggestion
>>> df.select(var_pop(df.id)).first()
```
##########
python/pyspark/sql/functions.py:
##########
@@ -1352,6 +1812,22 @@ def skewness(col: "ColumnOrName") -> Column:
Aggregate function: returns the skewness of the values in a group.
.. versionadded:: 1.6.0
+
+ Parameters
+ ----------
+ col : :class:`~pyspark.sql.Column` or str
+ target column to compute on.
+
+ Returns
+ -------
+ :class:`~pyspark.sql.Column`
+ skewness of given column.
+
+ Examples
+ --------
+ >>> df = spark.createDataFrame([[1],[1],[2]], ["c"])
+ >>> df.select(skewness(df.c)).first() # doctest: +ELLIPSIS
Review Comment:
```suggestion
>>> df.select(skewness(df.c)).first()
```
##########
python/pyspark/sql/functions.py:
##########
@@ -1064,15 +1164,57 @@ def log10(col: "ColumnOrName") -> Column:
Computes the logarithm of the given value in Base 10.
.. versionadded:: 1.4.0
+
+ Parameters
+ ----------
+ col : :class:`~pyspark.sql.Column` or str
+ column to calculate logarithm for.
+
+ Returns
+ -------
+ :class:`~pyspark.sql.Column`
+ logarithm of the given value in Base 10.
+
+ Examples
+ --------
+ >>> df = spark.range(1)
+ >>> df.select(log10(lit(100))).show()
+ +----------+
+ |LOG10(100)|
+ +----------+
+ | 2.0|
+ +----------+
"""
return _invoke_function_over_columns("log10", col)
def log1p(col: "ColumnOrName") -> Column:
"""
- Computes the natural logarithm of the given value plus one.
+ Computes the natural logarithm of the "given value plus one".
.. versionadded:: 1.4.0
+
+ Parameters
+ ----------
+ col : :class:`~pyspark.sql.Column` or str
+ column to calculate natural logarithm for.
+
+ Returns
+ -------
+ :class:`~pyspark.sql.Column`
+ natural logarithm of the "given value plus one".
+
+ Examples
+ --------
+ >>> import math
+ >>> df = spark.range(1)
+ >>> df.select(log1p(lit(math.e))).first() # doctest: +ELLIPSIS
+ Row(LOG1P(2.71828...)=1.31326...)
+
+ Same as:
+
+ >>> df.select(log(lit(math.e+1))).first() # doctest: +ELLIPSIS
Review Comment:
```suggestion
>>> df.select(log(lit(math.e+1))).first()
```
##########
python/pyspark/sql/functions.py:
##########
@@ -981,6 +988,12 @@ def cosh(col: "ColumnOrName") -> Column:
-------
:class:`~pyspark.sql.Column`
hyperbolic cosine of the angle, as if computed by
`java.lang.Math.cosh()`
+
+ Examples
+ --------
+ >>> df = spark.range(1)
+ >>> df.select(cosh(lit(1))).first() # doctest: +ELLIPSIS
Review Comment:
```suggestion
>>> df.select(cosh(lit(1))).first()
```
##########
python/pyspark/sql/functions.py:
##########
@@ -1013,12 +1033,19 @@ def csc(col: "ColumnOrName") -> Column:
Parameters
----------
col : :class:`~pyspark.sql.Column` or str
- Angle in radians
+ angle in radians.
Returns
-------
:class:`~pyspark.sql.Column`
- Cosecant of the angle.
+ cosecant of the angle.
+
+ Examples
+ --------
+ >>> import math
+ >>> df = spark.range(1)
+ >>> df.select(csc(lit(math.radians(90)))).first() # doctest: +ELLIPSIS
Review Comment:
```suggestion
>>> df.select(csc(lit(math.radians(90)))).first()
```
##########
python/pyspark/sql/functions.py:
##########
@@ -1124,11 +1326,19 @@ def sin(col: "ColumnOrName") -> Column:
Parameters
----------
col : :class:`~pyspark.sql.Column` or str
+ target column to compute on.
Returns
-------
:class:`~pyspark.sql.Column`
sine of the angle, as if computed by `java.lang.Math.sin()`
+
+ Examples
+ --------
+ >>> import math
+ >>> df = spark.range(1)
+ >>> df.select(sin(lit(math.radians(90)))).first() # doctest: +ELLIPSIS
Review Comment:
```suggestion
>>> df.select(sin(lit(math.radians(90)))).first()
```
##########
python/pyspark/sql/functions.py:
##########
@@ -1102,6 +1271,12 @@ def sec(col: "ColumnOrName") -> Column:
-------
:class:`~pyspark.sql.Column`
Secant of the angle.
+
+ Examples
+ --------
+ >>> df = spark.range(1)
+ >>> df.select(sec(lit(1.5))).first() # doctest: +ELLIPSIS
Review Comment:
```suggestion
>>> df.select(sec(lit(1.5))).first()
```
##########
python/pyspark/sql/functions.py:
##########
@@ -1037,6 +1084,22 @@ def expm1(col: "ColumnOrName") -> Column:
Computes the exponential of the given value minus one.
.. versionadded:: 1.4.0
+
+ Parameters
+ ----------
+ col : :class:`~pyspark.sql.Column` or str
+ column to calculate exponential for.
+
+ Returns
+ -------
+ :class:`~pyspark.sql.Column`
+ exponential less one.
+
+ Examples
+ --------
+ >>> df = spark.range(1)
+ >>> df.select(expm1(lit(1))).first() # doctest: +ELLIPSIS
Review Comment:
```suggestion
>>> df.select(expm1(lit(1))).first()
```
##########
python/pyspark/sql/functions.py:
##########
@@ -1188,6 +1411,13 @@ def tanh(col: "ColumnOrName") -> Column:
:class:`~pyspark.sql.Column`
hyperbolic tangent of the given value
as if computed by `java.lang.Math.tanh()`
+
+ Examples
+ --------
+ >>> import math
+ >>> df = spark.range(1)
+ >>> df.select(tanh(lit(math.radians(90)))).first() # doctest: +ELLIPSIS
Review Comment:
```suggestion
>>> df.select(tanh(lit(math.radians(90)))).first()
```
##########
python/pyspark/sql/functions.py:
##########
@@ -1295,6 +1651,22 @@ def stddev(col: "ColumnOrName") -> Column:
Aggregate function: alias for stddev_samp.
.. versionadded:: 1.6.0
+
+ Parameters
+ ----------
+ col : :class:`~pyspark.sql.Column` or str
+ target column to compute on.
+
+ Returns
+ -------
+ :class:`~pyspark.sql.Column`
+ standard deviation of given column.
+
+ Examples
+ --------
+ >>> df = spark.range(6)
+ >>> df.select(stddev(df.id)).first() # doctest: +ELLIPSIS
Review Comment:
```suggestion
>>> df.select(stddev(df.id)).first()
```
##########
python/pyspark/sql/functions.py:
##########
@@ -1168,6 +1384,13 @@ def tan(col: "ColumnOrName") -> Column:
-------
:class:`~pyspark.sql.Column`
tangent of the given value, as if computed by `java.lang.Math.tan()`
+
+ Examples
+ --------
+ >>> import math
+ >>> df = spark.range(1)
+ >>> df.select(tan(lit(math.radians(45)))).first() # doctest: +ELLIPSIS
Review Comment:
```suggestion
>>> df.select(tan(lit(math.radians(45)))).first()
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]