/ lib / pandas / _libs / sparse.pyi
sparse.pyi
 1  from typing import (
 2      Sequence,
 3      TypeVar,
 4  )
 5  
 6  import numpy as np
 7  
 8  from pandas._typing import npt
 9  
10  _SparseIndexT = TypeVar("_SparseIndexT", bound=SparseIndex)
11  
12  class SparseIndex:
13      length: int
14      npoints: int
15      def __init__(self): ...
16      @property
17      def ngaps(self) -> int: ...
18      @property
19      def nbytes(self) -> int: ...
20      @property
21      def indices(self) -> npt.NDArray[np.int32]: ...
22      def equals(self, other) -> bool: ...
23      def lookup(self, index: int) -> np.int32: ...
24      def lookup_array(self, indexer: npt.NDArray[np.int32]) -> npt.NDArray[np.int32]: ...
25      def to_int_index(self) -> IntIndex: ...
26      def to_block_index(self) -> BlockIndex: ...
27      def intersect(self: _SparseIndexT, y_: SparseIndex) -> _SparseIndexT: ...
28      def make_union(self: _SparseIndexT, y_: SparseIndex) -> _SparseIndexT: ...
29  
30  class IntIndex(SparseIndex):
31      indices: npt.NDArray[np.int32]
32      def __init__(
33          self, length: int, indices: Sequence[int], check_integrity: bool = ...
34      ): ...
35  
36  class BlockIndex(SparseIndex):
37      nblocks: int
38      blocs: np.ndarray
39      blengths: np.ndarray
40      def __init__(self, length: int, blocs: np.ndarray, blengths: np.ndarray): ...
41  
42  def make_mask_object_ndarray(
43      arr: npt.NDArray[np.object_], fill_value
44  ) -> npt.NDArray[np.bool_]: ...
45  def get_blocks(
46      indices: npt.NDArray[np.int32],
47  ) -> tuple[npt.NDArray[np.int32], npt.NDArray[np.int32]]: ...