fix: drop pandas index artefact in CSV preprocess_data_csv#306
Merged
Conversation
- Add 'index' to drop_variables in diver_survey_metadata_qc.json - Drop drop_variables from xarray Dataset after from_dataframe() conversion so that DataFrame index variables are also removed (not just columns) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent an unwanted pandas DataFrame index artefact (e.g., an index coordinate/variable) from propagating into the xarray Dataset produced during CSV ingestion, and configures the affected dataset to explicitly drop that artefact.
Changes:
- Add
"index"toschema_transformation.drop_variablesfordiver_survey_metadata_qc. - After
xr.Dataset.from_dataframe(df), drop configureddrop_variablesfrom the resulting xarrayDatasetto remove index-derived variables (not just DataFrame columns).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| aodn_cloud_optimised/lib/GenericParquetHandler.py | Drops configured variables from the xarray Dataset produced from CSV DataFrames to remove index artefacts. |
| aodn_cloud_optimised/config/dataset/diver_survey_metadata_qc.json | Configures the dataset to drop the index artefact via drop_variables. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
190
to
+192
| df = df.drop(columns=self.drop_variables, errors="ignore") | ||
| ds = xr.Dataset.from_dataframe(df) | ||
| ds = ds.drop_vars([v for v in self.drop_variables if v in ds], errors="ignore") |
Contributor
|
@leonardolaiolo can we add the |
Contributor
Author
|
yes @thommodin! push the commit! |
Merge recent main changes
Contributor
|
Just letting the checks run again. Had to patch up this with another merge I made before... |
leonardolaiolo
commented
Jul 14, 2026
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.
Uh oh!
There was an error while loading. Please reload this page.