zhengruifeng commented on code in PR #44794:
URL: https://github.com/apache/spark/pull/44794#discussion_r1458881539
##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -1488,31 +1533,66 @@ def acos(col: "ColumnOrName") -> Column:
Parameters
----------
col : :class:`~pyspark.sql.Column` or str
- target column to compute on.
+ The target column or expression to compute the inverse cosine on.
Returns
-------
:class:`~pyspark.sql.Column`
- inverse cosine of `col`, as if computed by `java.lang.Math.acos()`
+ A new column object representing the inverse cosine of the input.
Examples
--------
- >>> df = spark.range(1, 3)
- >>> df.select(acos(df.id)).show()
- +--------+
- |ACOS(id)|
- +--------+
- | 0.0|
- | NaN|
- +--------+
+ Example 1: Compute the inverse cosine of a column of numbers
+
+ >>> from pyspark.sql import functions as sf
+ >>> df = spark.createDataFrame([(-1.0,), (-0.5,), (0.0,), (0.5,), (1.0,)],
["value"])
+ >>> df.select("value",
+ ... sf.substring(sf.acos("value"), 0, 15).alias("ACOS(value)"),
+ ... sf.substring(sf.degrees(sf.acos("value")), 0,
5).alias("DEGREES(ACOS(value))")
+ ... ).show()
+ +-----+---------------+--------------------+
+ |value| ACOS(value)|DEGREES(ACOS(value))|
+ +-----+---------------+--------------------+
+ | -1.0|3.1415926535897| 180.0|
+ | -0.5|2.0943951023931| 120.0|
+ | 0.0|1.5707963267948| 90.0|
Review Comment:
```suggestion
| 0.0|1.5707963267...| 90.0|
```
and other similar places.
To make the result more stable: e.g. the doctest won't fail when we change
jdk version/python version/underlying engineer/etc.
--
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]