pyspark convert dataframe column from timestamp to string of “YYYY-MM-DD” format

前端 未结 3 1629
名媛妹妹
名媛妹妹 2021-02-20 07:09

In pyspark is there a way to convert a dataframe column of timestamp datatype to a string of format \'YYYY-MM-DD\' format?

3条回答
  •  抹茶落季
    2021-02-20 07:49

    from pyspark.sql.functions  import date_format
    
    df.withColumn("DateOnly", date_format('DateTime', "yyyy-MM-dd")).show()
    

提交回复
热议问题