I m working on NYK Green Taxi Data Jan 2017,I converted string column to Datetype now I can see only in row as alias , How to convert it into dataframe to Show() as table in Pickupdate column and DD-MM-YYYYFormat
-- lpep_pickup_datetime: string (nullable = true)
df2 = df.select(to_timestamp(df.lpep_pickup_datetime, 'yyyy-MM-dd HH:mm:ss').alias('pickup_datetime')).collect()
df2
[Row(pickup_datetime=datetime.datetime(2017, 1, 1, 0, 1, 15)), Row(pickup_datetime=datetime.datetime(2017, 1, 1, 0, 3, 34)), Row(pickup_datetime=datetime.datetime(2017, 1, 1, 0, 4, 2)), Row(pickup_datetime=datetime.datetime(2017, 1, 1, 0, 1, 40)), Row(pickup_datetime=datetime.datetime(2017, 1, 1, 0, 0, 51)), Row(pickup_datetime=datetime.datetime(2017, 1, 1, 0, 0, 28))
Output should be DD-MM-YYYY format Pickup_datetime Column like 1-1-2017 00:01:15
question from:
https://stackoverflow.com/questions/65623153/how-to-convert-pyspark-row-datetime-datetime-dataframe-to-column-name-datetype-w 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…