MCPcopy
hub / github.com/pandas-dev/pandas / copy

Method copy

pandas/io/pytables.py:1688–1745  ·  pandas/io/pytables.py::HDFStore.copy

Copy the existing store to a new file, updating in place. Parameters ---------- propindexes : bool, default True Restore indexes in copied file. keys : list, optional List of keys to include in the copy (defaults to all). over

(
        self,
        file,
        mode: str = "w",
        propindexes: bool = True,
        keys=None,
        complib=None,
        complevel: int | None = None,
        fletcher32: bool = False,
        overwrite: bool = True,
    )

Source from the content-addressed store, hash-verified

1686 return s
1687
1688 def copy(
1689 self,
1690 file,
1691 mode: str = class="st">"w",
1692 propindexes: bool = True,
1693 keys=None,
1694 complib=None,
1695 complevel: int | None = None,
1696 fletcher32: bool = False,
1697 overwrite: bool = True,
1698 ) -> HDFStore:
1699 class="st">"""
1700 Copy the existing store to a new file, updating in place.
1701
1702 Parameters
1703 ----------
1704 propindexes : bool, default True
1705 Restore indexes in copied file.
1706 keys : list, optional
1707 List of keys to include in the copy (defaults to all).
1708 overwrite : bool, default True
1709 Whether to overwrite (remove and replace) existing nodes in the new store.
1710 mode, complib, complevel, fletcher32 same as in HDFStore.__init__
1711
1712 Returns
1713 -------
1714 open file handle of the new store
1715 class="st">"""
1716 new_store = HDFStore(
1717 file, mode=mode, complib=complib, complevel=complevel, fletcher32=fletcher32
1718 )
1719 if keys is None:
1720 keys = list(self.keys())
1721 if not isinstance(keys, (tuple, list)):
1722 keys = [keys]
1723 for k in keys:
1724 s = self.get_storer(k)
1725 if s is not None:
1726 if k in new_store:
1727 if overwrite:
1728 new_store.remove(k)
1729
1730 data = self.select(k)
1731 if isinstance(s, Table):
1732 index: bool | list[str] = False
1733 if propindexes:
1734 index = [a.name for a in s.axes if a.is_indexed]
1735 new_store.append(
1736 k,
1737 data,
1738 index=index,
1739 data_columns=getattr(s, class="st">"data_columns", None),
1740 encoding=s.encoding,
1741 )
1742 else:
1743 new_store.put(k, data, encoding=s.encoding)
1744
1745 return new_store

Callers

nothing calls this directly

Calls 7

keysMethod · 0.95
get_storerMethod · 0.95
removeMethod · 0.95
selectMethod · 0.95
appendMethod · 0.95
putMethod · 0.95
HDFStoreClass · 0.85

Tested by

no test coverage detected