zhengruifeng commented on code in PR #44794:
URL: https://github.com/apache/spark/pull/44794#discussion_r1458879184
##########
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))")
Review Comment:
thanks, this looks pretty good.
btw, I guess we can use `sf.round` to make the result more stable.
--
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]