Segment Teleoperation Sessions Into Clean Training Episodes With Pandas

Last updated: November 29, 2026

Quick Overview

Given frame-level teleoperation logs (session_id, t, joint_speed, gripper), split each session into episodes wherever the operator was idle for at least a gap threshold, drop idle frames and episodes that are too short, and return one row per episode with duration, frame count and number of grasps.

Figure AI
Data Manipulation (SQL/Python)
Data Engineer
Figure AI
November 29, 2026
Data Engineer
Take-home Project
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


Given frame-level teleoperation logs (session_id, t, joint_speed, gripper), split each session into episodes wherever the operator was idle for at least a gap threshold, drop idle frames and episodes that are too short, and return one row per episode with duration, frame count and number of grasps.

Figure AI trains Helix-style policies on large volumes of human teleoperation, and raw sessions contain long idle stretches, resets, and operator breaks that hurt training if left in. A data engineering exercise like this checks grouped time-series manipulation in pandas and judgement about what makes a usable episode.

What the Interviewer Expects
  • Sorts by session and time before any diff
  • Uses groupby diff and cumsum to assign episode ids
  • Keeps episode boundaries within a session, never across
  • Defines grasp events from the gripper signal
  • Handles the all-idle case with a correctly shaped empty result
Key Topics to Cover
groupby and cumsum
Sessionization
Time-series cleaning
Training data quality
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you run this over 50 TB of logs instead of one DataFrame?
  • Idle by joint speed misses an operator who is holding still on purpose during a careful insertion. How would you avoid cutting those?
  • How would you attach task labels (for example 'place tote on shelf') to each episode?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

One row per frame. t is seconds since session start, joint_speed is a norm over arm joints in rad/s, gripper is 0 (open) to 1 (closed). Assumptions: a frame is moving if speed is at least 0.01...

Approach
  1. Sort by session_id, t.
  2. Keep only moving frames.
  3. Within each session, diff() the timestamps; a missing diff (first frame) or a gap at least the threshold marks a new episode.
  4. cumsum()...

Submit Your Answer
Markdown supported

Related Questions