PedestrianDynamics / PedestrianDynamics/PedPy

Add option to preserve additional columns when loading from txt

Open
#553 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

usability
Dominant language
Pascal
Stars
35
Forks
18
Avg merge
1d 14h
Merged PRs (30d)
2

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with load_trajectory_from_txt and _load_trajectory_data_from_txt, especially the pd.read_csv usecols and names arguments described in the issue. Add tests for preserving named extra columns and for unchanged default behavior, then update the API reference; done means extra values are available on traj.data while the default still drops them.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
data
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.