internals.pyi 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. from typing import (
  2. Iterator,
  3. Sequence,
  4. overload,
  5. )
  6. import numpy as np
  7. from pandas._typing import (
  8. ArrayLike,
  9. T,
  10. )
  11. from pandas import Index
  12. from pandas.core.arrays._mixins import NDArrayBackedExtensionArray
  13. from pandas.core.internals.blocks import Block as B
  14. def slice_len(slc: slice, objlen: int = ...) -> int: ...
  15. def get_blkno_indexers(
  16. blknos: np.ndarray, # int64_t[:]
  17. group: bool = ...,
  18. ) -> list[tuple[int, slice | np.ndarray]]: ...
  19. def get_blkno_placements(
  20. blknos: np.ndarray,
  21. group: bool = ...,
  22. ) -> Iterator[tuple[int, BlockPlacement]]: ...
  23. class BlockPlacement:
  24. def __init__(self, val: int | slice | np.ndarray): ...
  25. @property
  26. def indexer(self) -> np.ndarray | slice: ...
  27. @property
  28. def as_array(self) -> np.ndarray: ...
  29. @property
  30. def is_slice_like(self) -> bool: ...
  31. @overload
  32. def __getitem__(self, loc: slice | Sequence[int]) -> BlockPlacement: ...
  33. @overload
  34. def __getitem__(self, loc: int) -> int: ...
  35. def __iter__(self) -> Iterator[int]: ...
  36. def __len__(self) -> int: ...
  37. def delete(self, loc) -> BlockPlacement: ...
  38. def append(self, others: list[BlockPlacement]) -> BlockPlacement: ...
  39. class SharedBlock:
  40. _mgr_locs: BlockPlacement
  41. ndim: int
  42. values: ArrayLike
  43. def __init__(self, values: ArrayLike, placement: BlockPlacement, ndim: int): ...
  44. class NumpyBlock(SharedBlock):
  45. values: np.ndarray
  46. def getitem_block_index(self: T, slicer: slice) -> T: ...
  47. class NDArrayBackedBlock(SharedBlock):
  48. values: NDArrayBackedExtensionArray
  49. def getitem_block_index(self: T, slicer: slice) -> T: ...
  50. class Block(SharedBlock): ...
  51. class BlockManager:
  52. blocks: tuple[B, ...]
  53. axes: list[Index]
  54. _known_consolidated: bool
  55. _is_consolidated: bool
  56. _blknos: np.ndarray
  57. _blklocs: np.ndarray
  58. def __init__(
  59. self, blocks: tuple[B, ...], axes: list[Index], verify_integrity=True
  60. ): ...
  61. def get_slice(self: T, slobj: slice, axis: int = ...) -> T: ...