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 snapshot feature for pandas DataFrames, allowing users to create, restore, list, drop, and clear named snapshots of a DataFrame's state. The implementation includes a per-DataFrame snapshot store, deep copy safety, and comprehensive tests for all new functionality.
New DataFrame snapshot functionality:
DataFramefor snapshot management:snapshot,restore,list_snapshots,drop_snapshot,clear_snapshots, andsnapshot_info. These allow users to save and revert to previous states of a DataFrame, as well as manage snapshots.DataFrameSnapshotStoreclass in the new filepandas/core/frame_versioning.py, which handles the storage, retrieval, and metadata of DataFrame snapshots using deep copies for safety._ensure_snapshot_storeto attach and manage the snapshot store per DataFrame instance.pandas/tests/frame/test_versioning.pyto verify snapshot creation, restoration, inplace mutation, deletion, clearing, copy behavior, and error handling for missing snapshots.Integration and usage example:
asv_bench/benchmarks/bench_snapshot_memory.pydemonstrating how to create a snapshot and inspect memory usage, showcasing the new API in practice.