Skip to content

Add option to preserve additional columns when loading from txt #553

Description

@schroedtert

Summary

Add a parameter to load_trajectory_from_txt that preserves columns beyond the standard id, frame, x, y instead of silently dropping them.

Background / Context

The txt loader currently uses usecols=[0, 1, 2, 3] in pd.read_csv, discarding any columns past the first four. Users who have extra data in their txt files (e.g. z, group id, or other per-agent attributes) lose it on load. Constructing TrajectoryData directly from a DataFrame already preserves extra columns, so the file-based loader is inconsistent with the direct construction path.

Technical Details

  • Column selection happens in _load_trajectory_data_from_txt via usecols=[0, 1, 2, 3] and names=[ID_COL, FRAME_COL, X_COL, Y_COL]
  • The txt format has no column headers, so extra columns beyond the standard four have no names — the parameter should accept an optional mapping or list of names for those columns
  • TrajectoryData.__post_init__ already passes extra columns through unchanged, so no changes needed there

Acceptance Criteria

  • load_trajectory_from_txt accepts a new optional parameter to preserve additional columns
  • Extra columns are accessible on traj.data after loading
  • When the parameter is not set, existing behaviour is unchanged (extra columns are dropped)
  • New behaviour is covered by tests
  • New parameter is documented in the API reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    usabilityAnything increasing the usablity

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions