how do I get a number (seconds or days) from a time interval? #6407
Answered
by
lostmygithubaccount
lostmygithubaccount
asked this question in
Q&A
-
I computed the difference between two timestamp columns in Ibis, resulting in a table like: ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ open_for ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ interval(<IntervalUnit.SECOND: 's'>) │
├─────────────────────────────────────────────────────────────────────────┤
│ <DateOffset: days=0, microseconds=4202000000, months=0, nanoseconds=0> │
│ <DateOffset: days=0, microseconds=6159000000, months=0, nanoseconds=0> │
│ <DateOffset: days=0, microseconds=40979000000, months=0, nanoseconds=0> │ how do I then convert this column into an integer/float/number representing seconds (or days, if can have fractions)? attempting to cast this column to |
Beta Was this translation helpful? Give feedback.
Answered by
lostmygithubaccount
Jun 12, 2023
Replies: 1 comment 1 reply
-
this can be achieved using t = t.mutate(time_diff_col = _.time_col_A.epoch_seconds() - _.time_col_B.epoch_seconds()) (thanks to @cpcloud) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
lostmygithubaccount
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this can be achieved using
.epoch_seconds()
on the upstream columns and subtracting them(thanks to @cpcloud)