Empty frames will be returned as empty arrays of shape (0, ndim).
ndim = len(pos_columns)
grouped = iter(df.groupby(t_column)) // groupby sorts by default
// get the first frame to learn first frame number
cur_frame, frame = next(grouped)
cur_frame = int(cur_frame)
yield cur_frame, frame[pos_columns].values
cur_frame += 1
for frame_no, frame in grouped:
frame_no = int(frame_no)
while cur_frame < frame_no:
yield cur_frame, np.empty((0, ndim))
cur_frame += 1
yield cur_frame, frame[pos_columns].values
cur_frame += 1
def coords_from_df_iter(df_iter, pos_columns, t_column):
After Change
pos = pos[idxs]
unique_times, time_counts = np.unique(times, return_counts=True)
pos_by_frame = np.split(pos, np.cumsum(time_counts)[:-1])
idx = 0
for time in range(unique_times[0], unique_times[-1] + 1):
if time == unique_times[idx]: