Keyword-only key argument for pd.DataFrame.to_hdf()#3185
Keyword-only key argument for pd.DataFrame.to_hdf()#3185C-Achard merged 2 commits intoDeepLabCut:mainfrom
key argument for pd.DataFrame.to_hdf()#3185Conversation
This keyword-only usage is required for pandas 2.2 and higher.
There was a problem hiding this comment.
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", ...)todf.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.
|
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). |
C-Achard
left a comment
There was a problem hiding this comment.
Should be fine, very low risk
Motivation:
Pandas officially released version 3.0 (January 2026), but our code is not compatible with this version.
keyargument in pd.DataFrame.to_hdf() is no longer be supported. Pandas 2.2 and higher raise a warning for keyword-only usage of thekeyparameter, 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", ...)withdf.to_hdf(dataname, key="df_with_missing", ...)(and similar) where that was not yet implemented.