// Docs

Row transforms

Use map, flat_map, and filters over episode rows

Use row transforms when each episode can be handled independently in Python.

map

map takes one row and returns one row.

def add_frame_count(row):
    return row.update({"frame_count": row.num_frames})


pipeline = pipeline.map(add_frame_count)

This is the default transform for simple episode enrichment.

filter

Pass a Python predicate to keep or drop rows:

pipeline = pipeline.filter(lambda row: row.num_frames > 30)

For simple column predicates, vectorized filters are often faster; see Vectorized Transforms.

flat_map

flat_map takes one row and returns zero or more rows.

def split_by_camera(row):
    for camera, video in row.videos.items():
        yield row.update({"camera": camera, "video": video})


pipeline = pipeline.flat_map(split_by_camera)

Use this when one episode naturally becomes several examples.

DType hints

When a transform creates a column that a writer should treat as an asset or media value, pass dtypes:

pipeline = pipeline.map(
    lambda row: row.update({"clip": row.videos["front"]}),
    dtypes={"clip": mdr.datatype.video_path()},
)

See Schemas and DTypes.