itholic commented on a change in pull request #34863:
URL: https://github.com/apache/spark/pull/34863#discussion_r769286118
##########
File path: python/pyspark/sql/dataframe.py
##########
@@ -3076,15 +3080,17 @@ def transform(self, func: Callable[["DataFrame"],
"DataFrame"]) -> "DataFrame":
... return input_df.select([col(col_name).cast("int") for col_name
in input_df.columns])
>>> def sort_columns_asc(input_df):
... return input_df.select(*sorted(input_df.columns))
- >>> df.transform(cast_all_to_int).transform(sort_columns_asc).show()
+ >>> def mul_by(input_df, m):
+ ... return input_df.select([(col(col_name) * m).alias(col_name)
for col_name in input_df.columns])
+ >>>
df.transform(cast_all_to_int).transform(sort_columns_asc).transform(mul_by,
3).show()
+-----+---+
|float|int|
+-----+---+
- | 1| 1|
- | 2| 2|
+ | 3| 3|
+ | 6| 6|
+-----+---+
Review comment:
Can we keep the existing example and adding the new one to demonstrate
the both usage ??
--
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]