Skip to content

fix: drop pandas index artefact in CSV preprocess_data_csv#306

Merged
thommodin merged 5 commits into
mainfrom
update_CO_nrmn_index
Jul 14, 2026
Merged

fix: drop pandas index artefact in CSV preprocess_data_csv#306
thommodin merged 5 commits into
mainfrom
update_CO_nrmn_index

Conversation

@leonardolaiolo

@leonardolaiolo leonardolaiolo commented Jul 13, 2026

Copy link
Copy Markdown
Contributor
  • Add 'index' to drop_variables in all NRMN configs
  • Drop drop_variables from xarray Dataset after from_dataframe() conversion so that DataFrame index variables are also removed (not just columns)
  • Tested locally for:
    • diver_mobile_macroinvertebrate_abundance_qc
    • diver_survey_metadata_qc
    • diver_off_transect_species_observations_qc
    • diver_cryptobenthic_fish_abundance_qc
    • diver_benthic_cover_in_situ_qc
    • diver_site_information_qc
    • diver_reef_fish_abundance_biomass_qc

- 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>
Copilot AI review requested due to automatic review settings July 13, 2026 04:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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" to schema_transformation.drop_variables for diver_survey_metadata_qc.
  • After xr.Dataset.from_dataframe(df), drop configured drop_variables from the resulting xarray Dataset to 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")
@leonardolaiolo leonardolaiolo marked this pull request as draft July 13, 2026 05:07
@leonardolaiolo leonardolaiolo requested a review from thommodin July 13, 2026 05:51
@leonardolaiolo leonardolaiolo marked this pull request as ready for review July 13, 2026 23:45
@thommodin

Copy link
Copy Markdown
Contributor

@leonardolaiolo can we add the diver_photoquadrat_score_qc as well to this?

@leonardolaiolo

Copy link
Copy Markdown
Contributor Author

yes @thommodin! push the commit!

@thommodin

Copy link
Copy Markdown
Contributor

Just letting the checks run again. Had to patch up this with another merge I made before...

@thommodin thommodin merged commit b43cc6e into main Jul 14, 2026
4 of 7 checks passed
@thommodin thommodin deleted the update_CO_nrmn_index branch July 14, 2026 01:29
@thommodin thommodin restored the update_CO_nrmn_index branch July 14, 2026 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants