I have time column which has object data-type and contains value in the following format:
0 days 01:30:00.0
I want to change the above time column into the format of HH:mm:ss, so that it looks like in following format:
01:30:00
I used the following code to convert into the desired format:
df.withColumn('TIME_timestamp',F.to_timestamp("time", "HH:mm:ss")).show()
However, it returned the null column. Output produced by the above code is:
time| TIME_timestamp|
+-------------------+--------------+
0 days 00:00:00.0 | null|
0 days 00:30:00.0 | null|
0 days 01:00:00.0 | null|
0 days 01:30:00.0 | null|
0 days 02:00:00.0 | null|
0 days 02:30:00.0 | null|
+-------------------+---------------+
Could anyone guide where am I making the mistake?