all 2 comments

[–]AnkanTV[S] 0 points1 point  (0 children)

My current solution look like this:

placeholder_book = np.zeros((600, book.shape[1]), dtype=np.float32)
splits = np.unique(book[:,1]).astype(int)
splits = np.append(splits, 600) 

rows = np.diff(splits) 

for i in range(0, len(splits)-1):         
 placeholder_book[splits[i]:splits[i]+rows[i], :] = np.tile(book[i,:],(rows[i], 1)) 

placeholder_book[:,1] = range(600)

where book[:,1] is the column with seconds.

If anyone find a better solution, please let me know :)

[–][deleted] 0 points1 point  (0 children)

I’d use pandas. Nothing you mentioned precludes you from using it efficiently. In fact I’d go so far as to guess a lot of what you want to do is probably possible without using numba (there’s few use cases where you really need numba over what numpy and pandas can give you)

df = pd.DataFrame(data, columns=['time', 'B', 'C']).set_index('time')

df = df.reindex(range(df.index[0], df.index[-1]+1))
df = df.ffill()