wayneguow commented on code in PR #47343:
URL: https://github.com/apache/spark/pull/47343#discussion_r1683706137
##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -3671,16 +3671,84 @@ def regr_avgx(y: "ColumnOrName", x: "ColumnOrName") ->
Column:
Examples
--------
- >>> from pyspark.sql import functions as sf
- >>> x = (sf.col("id") % 3).alias("x")
- >>> y = (sf.randn(42) + x * 10).alias("y")
- >>> spark.range(0, 1000, 1, 1).select(x, y).select(
- ... sf.regr_avgx("y", "x"), sf.avg("x")
- ... ).show()
+ Example 1: All paris are non-null
+
+ >>> import pyspark.sql.functions as sf
+ >>> from pyspark.sql.types import IntegerType, StructField, StructType
+ >>> schema = StructType([
+ ... StructField('y', IntegerType(), True),
+ ... StructField('x', IntegerType(), True)
+ ... ])
+ >>> df = spark.createDataFrame([(1, 2), (2, 2), (2, 3), (2, 4)], schema)
Review Comment:
All suggestions received, let me optimize it.
--
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]