You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/02/25 07:29:19 UTC

[GitHub] Hellsen83 edited a comment on issue #23877: [SPARK-26449][PYTHON] Add transform method to DataFrame API

Hellsen83 edited a comment on issue #23877: [SPARK-26449][PYTHON] Add transform method to DataFrame API
URL: https://github.com/apache/spark/pull/23877#issuecomment-466900342
 
 
           >>> from pyspark.sql.functions import col
           >>> df = spark.createDataFrame([(1, 1.0), (2, 2.)], ["int", "float"])
           >>> def cast_all_to_int(input_df):
           ...     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()
           +-----+---+
           |float|int|
           +-----+---+
           |    1|  1|
           |    2|  2|
           +-----+---+
   
   `
   Thoughts, @srowen ?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org