passed a manager and a axes dict
(
cls,
mgr: Manager,
axes: dict[Literal["index", "columns"], Axes | None],
dtype: DtypeObj | None = None,
copy: bool = False,
)
| 263 | @final |
| 264 | @classmethod |
| 265 | def _init_mgr( |
| 266 | cls, |
| 267 | mgr: Manager, |
| 268 | axes: dict[Literal["index", "columns"], Axes | None], |
| 269 | dtype: DtypeObj | None = None, |
| 270 | copy: bool = False, |
| 271 | ) -> Manager: |
| 272 | """passed a manager and a axes dict""" |
| 273 | for a, axe in axes.items(): |
| 274 | if axe is not None: |
| 275 | axe = ensure_index(axe) |
| 276 | bm_axis = cls._get_block_manager_axis(a) |
| 277 | mgr = mgr.reindex_axis(axe, axis=bm_axis) |
| 278 | |
| 279 | # make a copy if explicitly requested |
| 280 | if copy: |
| 281 | mgr = mgr.copy(deep=True) |
| 282 | if dtype is not None: |
| 283 | # avoid further copies if we can |
| 284 | if ( |
| 285 | isinstance(mgr, BlockManager) |
| 286 | and len(mgr.blocks) == 1 |
| 287 | and mgr.blocks[0].values.dtype == dtype |
| 288 | ): |
| 289 | pass |
| 290 | else: |
| 291 | mgr = mgr.astype(dtype=dtype) |
| 292 | return mgr |
| 293 | |
| 294 | @final |
| 295 | @classmethod |
no test coverage detected