Skip to content

TimestampValue.add() create new Timestamp column from offset in float seconds #9224

Answered by cpcloud
jogam asked this question in Q&A
Discussion options

You must be logged in to vote

There are a couple mistakes in your example:

  1. You didn't import _ from Ibis
  2. You're dividing by 10**6 to convert seconds to microseconds when you should be multiplying.

There's also a bunch of unnecessary timedelta -> float conversion and list creation. You can do all that with numpy.

Finally, the solution to your actual problem is to cast to an interval with desired units.

Here's a cleaned up script that shows how to achieve what you want:

import numpy as np
import pandas as pd

from ibis.interactive import *

td_list = np.random.randint(5000, 30000, 60) / 10_000
timestamps = pd.date_range(start="2021-01-01 00:00:00", periods=60, freq="180s")

tbl = ibis.memtable({"timestamp": timestamps, 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jogam
Comment options

Answer selected by cpcloud
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants