Noobie Noobie - 1 year ago 41
Python Question

how to extract up to the minute component of a unix timestamp?

I have a list of POSIX timestamps such as

that I process using
which gives me a date format like:
year - month - day - hour - minute - seconds

However, for resampling purposes I just need to extract the timestamp up to the minute precision, that is
year - month - day - hour - minute
, but no seconds.

How can I do that using functions from the
module only (no Pandas)?


You can use the datetime.replace function:

import datetime
d = datetime.datetime.utcfromtimestamp(1331567982)
d.replace(second=0, microsecond=0)