internals.pyi 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. from collections.abc import (
  2. Iterator,
  3. Sequence,
  4. )
  5. from typing import (
  6. Self,
  7. final,
  8. overload,
  9. )
  10. import weakref
  11. import numpy as np
  12. from pandas._typing import (
  13. ArrayLike,
  14. npt,
  15. )
  16. from pandas import Index
  17. from pandas.core.internals.blocks import Block as B
  18. def slice_len(slc: slice, objlen: int = ...) -> int: ...
  19. def get_concat_blkno_indexers(
  20. blknos_list: list[npt.NDArray[np.intp]],
  21. ) -> list[tuple[npt.NDArray[np.intp], BlockPlacement]]: ...
  22. def get_blkno_indexers(
  23. blknos: np.ndarray, # int64_t[:]
  24. group: bool = ...,
  25. ) -> list[tuple[int, slice | np.ndarray]]: ...
  26. def get_blkno_placements(
  27. blknos: np.ndarray,
  28. group: bool = ...,
  29. ) -> Iterator[tuple[int, BlockPlacement]]: ...
  30. def update_blklocs_and_blknos(
  31. blklocs: npt.NDArray[np.intp],
  32. blknos: npt.NDArray[np.intp],
  33. loc: int,
  34. nblocks: int,
  35. ) -> tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]]: ...
  36. @final
  37. class BlockPlacement:
  38. def __init__(self, val: int | slice | np.ndarray) -> None: ...
  39. @property
  40. def indexer(self) -> np.ndarray | slice: ...
  41. @property
  42. def as_array(self) -> np.ndarray: ...
  43. @property
  44. def as_slice(self) -> slice: ...
  45. @property
  46. def is_slice_like(self) -> bool: ...
  47. @overload
  48. def __getitem__(
  49. self, loc: slice | Sequence[int] | npt.NDArray[np.intp]
  50. ) -> BlockPlacement: ...
  51. @overload
  52. def __getitem__(self, loc: int) -> int: ...
  53. def __iter__(self) -> Iterator[int]: ...
  54. def __len__(self) -> int: ...
  55. def delete(self, loc) -> BlockPlacement: ...
  56. def add(self, other) -> BlockPlacement: ...
  57. def append(self, others: list[BlockPlacement]) -> BlockPlacement: ...
  58. def tile_for_unstack(self, factor: int) -> npt.NDArray[np.intp]: ...
  59. class Block:
  60. _mgr_locs: BlockPlacement
  61. ndim: int
  62. values: ArrayLike
  63. refs: BlockValuesRefs
  64. def __init__(
  65. self,
  66. values: ArrayLike,
  67. placement: BlockPlacement,
  68. ndim: int,
  69. refs: BlockValuesRefs | None = ...,
  70. ) -> None: ...
  71. def slice_block_rows(self, slicer: slice) -> Self: ...
  72. class BlockManager:
  73. blocks: tuple[B, ...]
  74. axes: list[Index]
  75. _known_consolidated: bool
  76. _is_consolidated: bool
  77. _blknos: np.ndarray
  78. _blklocs: np.ndarray
  79. def __init__(
  80. self, blocks: tuple[B, ...], axes: list[Index], verify_integrity=...
  81. ) -> None: ...
  82. def get_slice(self, slobj: slice, axis: int = ...) -> Self: ...
  83. def _rebuild_blknos_and_blklocs(self) -> None: ...
  84. class BlockValuesRefs:
  85. referenced_blocks: list[weakref.ref]
  86. def __init__(self, blk: Block | None = ...) -> None: ...
  87. def add_reference(self, blk: Block) -> None: ...
  88. def add_index_reference(self, index: Index) -> None: ...
  89. def has_reference(self) -> bool: ...