Skip to content

Commit 3dd4dce

Browse files
committed
ENH: Refactor KeyError messages for DataFrame snapshot methods for improved readability
1 parent ee251a3 commit 3dd4dce

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

pandas/core/frame.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@
270270

271271
from pandas.io.formats.style import Styler
272272

273-
from pandas.core.frame_versioning import DataFrameSnapshotStore
273+
from pandas.core.frame_versioning import DataFrameSnapshotStore
274274

275275
# ---------------------------------------------------------------------
276276
# Docstring templates
@@ -14393,13 +14393,10 @@ def restore(self, name: str, inplace: bool = False):
1439314393
"""
1439414394
store = getattr(self, "_version_snapshots", None)
1439514395
if store is None:
14396-
raise KeyError(f"No snapshots present for this DataFrame (requested: {name})")
14396+
raise KeyError(f"No snapshots present for this DataFrame(requested:{name})")
1439714397
restored = store.restore(name)
1439814398
if inplace:
14399-
# Replace internal state. Using _mgr replacement is more correct than __dict__ update.
14400-
# Many pandas internals use the attribute _mgr for BlockManager. Use it cautiously.
1440114399
try:
14402-
# pandas >= 1.x use _mgr (BlockManager); adapt if different in your branch.
1440314400
object.__setattr__(self, "_mgr", restored._mgr)
1440414401
# also copy other key attrs
1440514402
object.__setattr__(self, "axes", restored.axes)
@@ -14423,7 +14420,7 @@ def drop_snapshot(self, name: str) -> None:
1442314420
"""
1442414421
store = getattr(self, "_version_snapshots", None)
1442514422
if store is None:
14426-
raise KeyError(f"No snapshots present for this DataFrame (requested drop: {name})")
14423+
raise KeyError(f"No snapshots present for this DataFrame(requested drop:{name})")
1442714424
store.drop(name)
1442814425

1442914426
def clear_snapshots(self) -> None:

0 commit comments

Comments
 (0)