dataframe
¶
ColumnManifest
¶
Bases: TypedDict
Manifest of all columns available for plotting.
-
Code Reference
mujoco_mojoutils
-
Code Reference
mujoco_mojoutilslayersdojosensai
rotatable_vectors
instance-attribute
¶
All columns in self.all which are available be rotated using self.available_quats. Groups tagged scalar are left out.
available_quats
instance-attribute
¶
All quaternion names which have enough information to rotate self.rotateable_vectors.
column_metadata
instance-attribute
¶
column_metadata: dict[str, ColumnMetadata]
All per-column signal metadata keyed by column name, for every column that has any metadata. Populated only when column_metadata is passed to get_manifest().
MojoNamespace
¶
Enhanced Polars DataFrame for MuJoCo Mojo telemetry.
Supports hierarchical signal filtering and common physics transformations.
Source code in src/mujoco_mojo/utils/dataframe.py
columns
property
¶
The frame's columns as parsed Columns (category, subgroups, and attr), in frame order. A column whose name does not follow the telemetry grammar (for example a Lab output with a free-form label) is left out.
Parsing is cached per name, so this stays cheap for frames with thousands of columns.
rotatable_bases
property
¶
Returns the unique base names for 3-component vectors (x, y, z).
quaternion_bases
property
¶
Returns the unique base names for 4-component quaternions (w, x, y, z).
rotatable_columns
property
¶
Returns column names ending in :x, :y, or :z (excluding quaternions which end with :w).
quaternion_columns
property
¶
Returns all columns that form a full quaternion group. Specifically looks for columns ending with quat:w, quat:x, quat:y, quat:z.
select
¶
Keeps every column that is one of columns or lies beneath one, as decided by Column.covers. A string is parsed with Column.parse.
A partial column selects a subtree, so select("Bodies/box1") keeps Bodies/box1/xpos:x and Bodies/box1:ke_trans, while select(Column(category="Bodies", attr="x")) keeps every body's :x components. Names are matched as parts, never as patterns (each part is escaped), so an object name containing regex characters is matched literally.
Source code in src/mujoco_mojo/utils/dataframe.py
pose_at
¶
pose_at(
index: int,
source: Column | str,
*,
pos_channel: str = "xpos",
quat_channel: str = "quat",
) -> PoseQuat
The pose of source (for example Sites/A) at row index.
Reads only the seven pose columns of that one row, so the cost does not grow with the size of the frame. Raises a ValueError naming every missing column. For every row at once use pose_arrays.
Source code in src/mujoco_mojo/utils/dataframe.py
pose_arrays
¶
pose_arrays(
source: Column | str,
*,
pos_channel: str = "xpos",
quat_channel: str = "quat",
) -> tuple[ndarray, ndarray]
The pose of source over the whole frame as plain arrays: positions (n_rows, 3) and quaternions (n_rows, 4) in MJCF w, x, y, z order.
Prefer this over calling pose_at per row for a trajectory: it makes one array copy per group, where a per-row PoseQuat would validate a pydantic model for every row. Raises a ValueError naming every missing column.
Source code in src/mujoco_mojo/utils/dataframe.py
select_category
¶
select_category(
category: SignalCategory | str,
) -> MojoDataFrame
Filter columns belonging to a specific SignalCategory (e.g., 'Bodies').
select_name
¶
select_name(name: str) -> MojoDataFrame
General filter for columns associated with a specific object name (e.g., 'racket').
Source code in src/mujoco_mojo/utils/dataframe.py
select_channel
¶
select_channel(channel: str) -> MojoDataFrame
Selects all components of a specific channel across any category.
Matches the logical 'folder' before the attribute separator. Example: 'xpos' matches 'Bodies/Hand/xpos:x' and 'Bodies/Hand/xpos:y'.
Source code in src/mujoco_mojo/utils/dataframe.py
select_attribute
¶
select_attribute(attr: str) -> MojoDataFrame
Selects a specific attribute across all categories and objects. Matches columns ending in ':attr' (e.g. attr='x' matches 'Bodies/racket/xpos:x' and 'Sensors/gyro/data:x').
Source code in src/mujoco_mojo/utils/dataframe.py
select_path_part
¶
select_path_part(part: str) -> MojoDataFrame
Selects any column whose full path contains part as a substring, anywhere.
Unlike the other select_* methods, this does not anchor to a specific position in the path (category, name, channel, or attribute) - it matches part wherever it appears.
Example
select_path_part("racket") matches Bodies/racket/xpos:x, Custom/MyGroup:racket, and Bodies/racket_arm/xpos:x.
Source code in src/mujoco_mojo/utils/dataframe.py
select_joint
¶
select_joint(name: JointName) -> MojoDataFrame
Select all signals belonging to a specific Joint (qpos, qvel, etc.).
select_geom
¶
select_geom(name: GeomName) -> MojoDataFrame
Select all signals associated with a specific Geom (contacts, etc.).
select_sensor
¶
select_sensor(name: SensorName) -> MojoDataFrame
select_actuator
¶
select_actuator(name: ActuatorName) -> MojoDataFrame
select_tendon
¶
select_tendon(name: TendonName) -> MojoDataFrame
select_camera
¶
select_camera(name: CameraName) -> MojoDataFrame
select_equality
¶
select_equality(name: EqualityName) -> MojoDataFrame
Select force/error data from an Equality constraint.
select_plugin
¶
select_plugin(name: InstanceName) -> MojoDataFrame
Select custom state data from a specific Plugin Instance.
select_flex
¶
select_flex(name: FlexName) -> MojoDataFrame
Select vertex/stress data from a Deformable Flex object.
get_manifest
¶
get_manifest(
extra_columns: list[str] | None = None,
column_metadata: Mapping[str, ColumnMetadata]
| None = None,
) -> ColumnManifest
Returns the structured manifest used by the frontend. extra_columns are appended to all and included in rotatable/quat discovery. Pass column_metadata (from MojoDataFrame.read_column_metadata()) to populate column_metadata, and to leave out any group tagged scalar, which is not a vector or a quaternion and so is never offered for rotation (matching change_frame).
Source code in src/mujoco_mojo/utils/dataframe.py
with_unit_system
¶
with_unit_system(
target: UnitSystem,
*,
path: Path | str | None = None,
column_metadata: Mapping[str, ColumnMetadata]
| None = None,
assume_source: UnitSystem | None = None,
) -> MojoDataFrame
Converts all columns with known units into the target unit system.
For each column whose metadata carries a concrete "unit" key, applies a unit conversion from that stored unit into the equivalent unit in target. If assume_source is given, columns that only carry a "dimension" key (no concrete unit) are treated as if their source unit is the corresponding unit in assume_source, so they are converted too.
All conversions are collected and applied in a single with_columns() call (Polars handles the vectorised execution across columns), so this is equivalent in cost to one pass over the data regardless of how many unit groups there are.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
UnitSystem
|
The target unit system (e.g. |
required |
path
|
Path | str | None
|
Path to the parquet file to read column metadata from. Used when |
None
|
column_metadata
|
Mapping[str, ColumnMetadata] | None
|
Pre-loaded metadata dict (from |
None
|
assume_source
|
UnitSystem | None
|
When set, columns with only a |
None
|
Source code in src/mujoco_mojo/utils/dataframe.py
| Python | |
|---|---|
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 | |
change_frame
¶
change_frame(
quat_base: str,
origin_base: str,
*,
path: Path | str | None = None,
column_metadata: Mapping[str, ColumnMetadata]
| None = None,
invert: bool = True,
) -> MojoDataFrame
Re-expresses every tagged point/vector/quaternion column in this frame relative to the frame defined by origin_base (position) and quat_base (orientation).
Applies the correct transform per column by its declared transform_type: points are translated then rotated, vectors are rotated only, and quaternions are composed (q' = q_b^-1 (x) q). Every rotatable/quaternion column in the frame must be tagged (see mujoco_mojo.utils.signal_metadata.TransformType) or this raises - there is no untagged fallback, since guessing the wrong kind is exactly the silent-corruption bug this method exists to prevent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
quat_base
|
str
|
Prefix for the [x,y,z,w] quaternion group giving the target frame's orientation in world coordinates (e.g. 'Bodies/chassis/xquat'). |
required |
origin_base
|
str
|
Prefix for the [x,y,z] position group giving the target frame's origin in world coordinates (e.g. 'Bodies/chassis/xpos'). |
required |
path
|
Path | str | None
|
Path to the parquet file to read column metadata from. Used when |
None
|
column_metadata
|
Mapping[str, ColumnMetadata] | None
|
Pre-loaded metadata dict (from |
None
|
invert
|
bool
|
If True (default), performs a world-to-local transform into the target frame; if False, reverses it (local-to-world). |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
MojoDataFrame
|
DataFrame with every point/vector/quaternion column re-expressed in the target frame. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/mujoco_mojo/utils/dataframe.py
with_filter_map
¶
with_filter_map(
filter_map: dict[str, list[AnyFilter]],
omit_time: bool = True,
) -> MojoDataFrame
Applies specific filter stacks to mapped columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter_map
|
dict[str, list[AnyFilter]]
|
Dictionary mapping column names to a list of filters. |
required |
omit_time
|
bool
|
If True, skips the 'time' column even if present in the map. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
MojoDataFrame
|
DataFrame with the transformed columns overwritten. |
Source code in src/mujoco_mojo/utils/dataframe.py
with_filters
¶
with_filters(
filters: list[AnyFilter],
columns: list[str] | None = None,
omit_time: bool = True,
) -> MojoDataFrame
Applies a sequential stack of filters to the specified or all numeric columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filters
|
list[AnyFilter]
|
List of Filter objects to apply in order (e.g., LowPass -> Derivative). |
required |
columns
|
list[str] | None
|
Specific columns to transform. If None, applies to all available columns. Defaults to None. |
None
|
omit_time
|
bool
|
If True, prevents filters from being applied to the 'time' column. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
MojoDataFrame
|
DataFrame with the transformed columns overwritten. |