Skip to content
Advertisement

transform a list of datetimes in a pandas column to list of strings

I have the following pandas dataframe

JavaScript

I would like to transform each element of the lists in the time column to a string with the format '%Y/%m/%d %H:%M:%S'

I know I can do this:

JavaScript

to yield the value '2021/10/20 14:29:51',

but I do not know how to do this operation for every string element of each list in the time column.

Any help ?

Advertisement

Answer

You just need to use list comprehension inside apply after converting string lists to actual lists with eval:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement