Skip to content

Keyword-only key argument for pd.DataFrame.to_hdf()#3185

Merged
C-Achard merged 2 commits intoDeepLabCut:mainfrom
deruyter92:jaap/update_pandas_compatibility_to_hdf
Feb 13, 2026
Merged

Keyword-only key argument for pd.DataFrame.to_hdf()#3185
C-Achard merged 2 commits intoDeepLabCut:mainfrom
deruyter92:jaap/update_pandas_compatibility_to_hdf

Conversation

@deruyter92
Copy link
Copy Markdown
Collaborator

@deruyter92 deruyter92 commented Jan 22, 2026

Motivation:
Pandas officially released version 3.0 (January 2026), but our code is not compatible with this version.

  • Positional usage of the key argument in pd.DataFrame.to_hdf() is no longer be supported. Pandas 2.2 and higher raise a warning for keyword-only usage of the key parameter, and raise an error for pandas version 3.0. This was already implemented in most of the code, but this PR addresses the remaining places where that was not the case.

Changes:
This PR replaces df.to_hdf(dataname, "df_with_missing", ...) with df.to_hdf(dataname, key="df_with_missing", ...) (and similar) where that was not yet implemented.

@deruyter92 deruyter92 marked this pull request as ready for review February 2, 2026 10:00
@deruyter92 deruyter92 added the Another package code issue Bug/issue that relates to a dlc dependency label Feb 2, 2026
@deruyter92 deruyter92 requested a review from Copilot February 4, 2026 15:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 updates pd.DataFrame.to_hdf() calls across multiple files to make the key parameter keyword-only, ensuring compatibility with Pandas 3.0 (released January 2026). This change addresses deprecation warnings in Pandas 2.2+ and errors in Pandas 3.0 where positional usage of the key argument is no longer supported.

Changes:

  • Updated all remaining instances of df.to_hdf(path, "key_name", ...) to df.to_hdf(path, key="key_name", ...)
  • Applied changes consistently across test scripts, examples, and core library modules
  • Ensured compatibility with Pandas 3.0 API requirements

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
testscript_cli.py Updated to_hdf() call to use keyword-only key parameter
examples/testscript_transreid.py Updated two to_hdf() calls to use keyword-only key parameter
examples/testscript_pretrained_models.py Updated two to_hdf() calls to use keyword-only key parameter
examples/testscript_multianimal.py Updated two to_hdf() calls to use keyword-only key parameter
examples/testscript_mobilenets.py Updated two to_hdf() calls to use keyword-only key parameter
examples/testscript_deterministicwithResNet152.py Updated to_hdf() call to use keyword-only key parameter
deeplabcut/refine_training_dataset/tracklets.py Updated to_hdf() call in save method to use keyword-only key parameter
deeplabcut/refine_training_dataset/stitch.py Updated to_hdf() call to use keyword-only key parameter for "tracks"
deeplabcut/refine_training_dataset/outlier_frames.py Updated to_hdf() call to use keyword-only key parameter
deeplabcut/post_processing/analyze_skeleton.py Updated to_hdf() call to use keyword-only key parameter
deeplabcut/pose_estimation_tensorflow/core/evaluate.py Updated to_hdf() call to use keyword-only key parameter
deeplabcut/modelzoo/generalized_data_converter/utils.py Updated to_hdf() call to use keyword-only key parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@deruyter92 deruyter92 requested a review from MMathisLab February 4, 2026 15:40
@deruyter92
Copy link
Copy Markdown
Collaborator Author

Minimal changes. Should help to prevent issues when users have a wrong pandas installation (also prevented by our restricted requirements, but good to address anyway).

@deruyter92 deruyter92 added the bug fix! fix for a real buggy one... label Feb 4, 2026
@C-Achard C-Achard self-requested a review February 13, 2026 13:26
Copy link
Copy Markdown
Collaborator

@C-Achard C-Achard left a comment

Choose a reason for hiding this comment

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

Should be fine, very low risk

@C-Achard C-Achard merged commit 20acdc6 into DeepLabCut:main Feb 13, 2026
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Another package code issue Bug/issue that relates to a dlc dependency bug fix! fix for a real buggy one...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants