Converting epoch to string in format yyyy-mm-dd, or maybe it is not necessary

dieter dieter at handshake.de
Fri Jun 2 02:20:06 EDT 2017


zljubisic at gmail.com writes:

> I have a dataframe with epoh dates, something like this:
>
> df = pd.DataFrame( { 'epoch' : [1493928008, 1493928067, 1493928127, 1493928310, 1493928428, 1493928547]}) 
>
> I want to create a new column with epoch converted to yyyy-mm-dd as string.

"epoch" dates usually mean seconds since 1.1.1970, represented
as an integer or float. A single epoch date is usually not represented
as a list (as above).
For details, read the head of the "time" module documentation.

The "time" module contains 2 functions to convert from an
"epoch date" to a time tuple: "gmtime"
(this gives an UTC or Greenwich Mean time tuple) and "localtime" (this
gives a time tuple represented in the local time zone).

You can use "time.strftime" to get a string representation (according
to a format you specify) from a time tuple.


Again, the documentation of the "time" module tells the details.




More information about the Python-list mailing list