How do you convert unix timestamps (epoch) to dates/datetime/timestamp? #10757
-
E.g. given a basic example:
I've seen the epoch_seconds temporal expression: https://ibis-project.org/reference/expression-temporal.html#ibis.expr.types.temporal.TimestampValue.epoch_seconds But I don't see any word in the docs on how to convert from UNIX to datetime/timestamp column. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
import ibis
unix = 1738260000
ibis.date(1970, 1, 1).add(ibis.interval(unix))
>NotImplemented Is that right? Could I just confirm that there is no way of doing this at the moment? Edit: import ibis
unix = 1738260000
(ibis.date(1970, 1, 1).add(ibis.interval(unix).as_unit('D'))).as_scalar().execute()
>datetime.date(2025, 1, 30)
When it should return:
datetime.datetime.utcfromtimestamp(unix)
>datetime.datetime(2025, 1, 30, 18, 0) |
Beta Was this translation helpful? Give feedback.
There should be an
as_timestamp
method on the column you can use for this (and then specify the unit that that int-column is representing (usually seconds)