Repository navigation
Conversation
Member
Author
There was a problem hiding this comment.
🟡 Changes recommended
Scaled integer columns are multiplied in float64 before conversion to the requested wider precision, causing irreversible precision loss for large uint64 values.
1 open issue
What changed in this PR
Adds opt-in floating-point precision and particle-ID indexing to the Python dataframe conversions while preserving default behavior.
Changes:
- Adds
floatingto pandas, cuDF, and Dask conversions, with precision-aware SI scaling. - Adds
index="id"to pandas and cuDF conversions, including iteration-aware indexing and duplicate-ID warnings. - Adds conversion tests, usage documentation, and a precision example.
| File | Description |
|---|---|
test/python/unittest/API/APITest.py |
Tests defaults, precision conversion, ID indexing, and Dask output. |
src/binding/python/openpmd_api/DataFrame.py |
Implements precision selection and particle-ID indexing. |
src/binding/python/openpmd_api/DaskDataFrame.py |
Passes precision selection through delayed chunk reads. |
examples/11_particle_dataframe.py |
Demonstrates requesting double-precision columns. |
docs/source/analysis/rapids.rst |
Documents cuDF precision and indexing options. |
docs/source/analysis/pandas.rst |
Explains precision control and particle-aligned comparisons. |
docs/source/analysis/dask.rst |
Documents precision control and explicit ID indexing. |
Review effort: Balanced
Comment on lines
+31
to
+32
| if floating is not None and np.issubdtype(data.dtype, np.floating): | ||
| data = data.astype(np.promote_types(data.dtype, floating), copy=False) |
Member
Author
There was a problem hiding this comment.
Wow, I thought we already safely deselected ints by filtering by floating point types
Add `floating=` to `to_df`, `to_cudf` and `to_dask`. It sets the type of floating-point columns and applies `unit_SI` in the wider of the stored and the requested precision, which casting afterwards cannot do. Add `index="id"` to `to_df` and `to_cudf` to compare particles by id instead of by row. Series use `(iteration, id)` as a unique index. The default index is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ax3l
force-pushed
the
topic-df-floating-index
branch
from
November 10, 2026 18:49
25d5d9d to
6d09e85
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Two opt-in arguments for the particle dataframe functions. Existing calls behave as before.
floating=np.float64(to_df,to_cudf,to_dask): sets the type of floating-point columns.unit_SIis applied in the wider of the stored and the requested precision, so casting afterwards is not equivalent: it keeps the rounding of a scaling in single precision.index="id"(to_df,to_cudf): uses the particle id as the index and replaces.to_df().set_index("id"). Row-aligned arithmetic between iterations silently compares different particles once their order changes. Series use(iteration, id), which stays unique across iterations.Notes
.to_df().set_index("id")anddf["id"], andidis optional in the standard, so the index type would depend on the file.index="id"raisesValueErrorif a species has noidrecord, and warns if ids are not unique, because aligning on duplicates multiplies rows.to_daskhas noindex=: a per-partition id index gave all-NaN differences once particles changed partition. The docs show.to_dask().set_index("id"), which reads all chunks.Testing
Adds the first
to_dftests (testDataFrame*).Unittest.pyand example 11 pass locally with pandas 2.3.3 on Python 3.12 and, with dask 2025.12.0, on Python 3.14.Not tested:
to_cudfhas not been run (only checked against the cuDF source), and neither has pandas 3.🤖 Generated with Claude Code