diff --git a/python/pyspark/sql/functions.py b/python/pyspark/sql/functions.py index 645244209772..e418c0d11f8f 100644 --- a/python/pyspark/sql/functions.py +++ b/python/pyspark/sql/functions.py @@ -377,6 +377,23 @@ def cosh(col): return _invoke_function_over_column("cosh", col) +def cot(col): + """ + .. versionadded:: 3.3.0 + + Parameters + ---------- + col : :class:`~pyspark.sql.Column` or str + Angle in radians + + Returns + ------- + :class:`~pyspark.sql.Column` + Cotangent of the angle. + """ + return _invoke_function_over_column("cot", col) + + @since(1.4) def exp(col): """ diff --git a/python/pyspark/sql/functions.pyi b/python/pyspark/sql/functions.pyi index 5c39706176a9..143fa133f4fe 100644 --- a/python/pyspark/sql/functions.pyi +++ b/python/pyspark/sql/functions.pyi @@ -298,6 +298,7 @@ def collect_set(col: ColumnOrName) -> Column: ... def column(col: str) -> Column: ... def cos(col: ColumnOrName) -> Column: ... def cosh(col: ColumnOrName) -> Column: ... +def cot(col: ColumnOrName) -> Column: ... def count(col: ColumnOrName) -> Column: ... def cume_dist() -> Column: ... def degrees(col: ColumnOrName) -> Column: ... diff --git a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala index c7be437b8c08..781a2dd5649e 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala @@ -1800,6 +1800,15 @@ object functions { */ def cosh(columnName: String): Column = cosh(Column(columnName)) + /** + * @param e angle in radians + * @return cotangent of the angle + * + * @group math_funcs + * @since 3.3.0 + */ + def cot(e: Column): Column = withExpr { Cot(e.expr) } + /** * Computes the exponential of the given value. *