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.
This pull request introduces a new versioning feature for
DataFrameobjects, allowing users to create, restore, list, drop, and clear named snapshots of a DataFrame's state. This is implemented via a per-instance snapshot store, and is thoroughly tested to ensure correct behavior. The changes add new methods toDataFrame, a supporting module, and a dedicated test suite.New DataFrame snapshot/versioning API:
DataFrame:snapshot,restore,list_snapshots,drop_snapshot,clear_snapshots, andsnapshot_info, enabling users to save and restore DataFrame states by name or timestamp._ensure_snapshot_storeto manage per-instance snapshot storage.Supporting infrastructure:
pandas/core/frame_versioning.pywith theDataFrameSnapshotStoreclass, handling deep copies of DataFrames for snapshot storage and retrieval, and managing snapshot metadata.pandas/core/frame.pyto includeOptionaland the new snapshot store module. [1] [2]Testing:
pandas/tests/frame/test_versioning.pycovering all new snapshot-related behaviors, including edge cases and error handling.