HyukjinKwon commented on code in PR #37437:
URL: https://github.com/apache/spark/pull/37437#discussion_r941896980


##########
python/pyspark/sql/group.py:
##########
@@ -261,17 +413,69 @@ def pivot(self, pivot_col: str, values: 
Optional[List["LiteralType"]] = None) ->
 
         Examples
         --------
-        # Compute the sum of earnings for each year by course with each course 
as a separate column
-
-        >>> df4.groupBy("year").pivot("course", ["dotNET", 
"Java"]).sum("earnings").collect()
-        [Row(year=2012, dotNET=15000, Java=20000), Row(year=2013, 
dotNET=48000, Java=30000)]
-
-        # Or without specifying column values (less efficient)
-
-        >>> df4.groupBy("year").pivot("course").sum("earnings").collect()
-        [Row(year=2012, Java=20000, dotNET=15000), Row(year=2013, Java=30000, 
dotNET=48000)]
-        >>> 
df5.groupBy("sales.year").pivot("sales.course").sum("sales.earnings").collect()
-        [Row(year=2012, Java=20000, dotNET=15000), Row(year=2013, Java=30000, 
dotNET=48000)]
+        >>> from pyspark.sql import Row
+        >>> spark = SparkSession.builder.master("local[4]").appName("sql.group 
tests").getOrCreate()

Review Comment:
   https://github.com/apache/spark/pull/37457



-- 
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]

Reply via email to