| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
from typing import Any, Iterable, Iterator, Literal, Mapping, Sequence, Type, TypeVar |
| 4 |
|
| 5 |
from .compute import CastOptions |
| 6 |
|
| 7 |
class DataType: ... |
| 8 |
|
| 9 |
def string() -> DataType: ... |
| 10 |
def null() -> DataType: ... |
| 11 |
def bool_() -> DataType: ... |
| 12 |
def int8() -> DataType: ... |
| 13 |
def int16() -> DataType: ... |
| 14 |
def int32() -> DataType: ... |
| 15 |
def int64() -> DataType: ... |
| 16 |
def uint8() -> DataType: ... |
| 17 |
def uint16() -> DataType: ... |
| 18 |
def uint32() -> DataType: ... |
| 19 |
def uint64() -> DataType: ... |
| 20 |
def float16() -> DataType: ... |
| 21 |
def float32() -> DataType: ... |
| 22 |
def float64() -> DataType: ... |
| 23 |
def date32() -> DataType: ... |
| 24 |
def date64() -> DataType: ... |
| 25 |
def binary(length: int = -1) -> DataType: ... |
| 26 |
def large_binary() -> DataType: ... |
| 27 |
def large_string() -> DataType: ... |
| 28 |
def month_day_nano_interval() -> DataType: ... |
| 29 |
def time32(unit: Literal["s", "ms", "us", "ns"]) -> DataType: ... |
| 30 |
def time64(unit: Literal["s", "ms", "us", "ns"]) -> DataType: ... |
| 31 |
def timestamp( |
| 32 |
unit: Literal["s", "ms", "us", "ns"], tz: str | None = None |
| 33 |
) -> DataType: ... |
| 34 |
def duration(unit: Literal["s", "ms", "us", "ns"]) -> DataType: ... |
| 35 |
|
| 36 |
class MemoryPool: ... |
| 37 |
class Schema: ... |
| 38 |
class Field: ... |
| 39 |
class NativeFile: ... |
| 40 |
|
| 41 |
class Scalar: |
| 42 |
def as_py(self) -> Any: ... |
| 43 |
|
| 44 |
A = TypeVar("A", bound="_PandasConvertible") |
| 45 |
|
| 46 |
class _PandasConvertible: |
| 47 |
@property |
| 48 |
def type(self) -> DataType: ... # noqa: A003 |
| 49 |
def cast( |
| 50 |
self: A, |
| 51 |
target_type: DataType | None = None, |
| 52 |
safe: bool = True, |
| 53 |
options: CastOptions | None = None, |
| 54 |
) -> A: ... |
| 55 |
def __getitem__(self, index: int) -> Scalar: ... |
| 56 |
def __iter__(self) -> Any: ... |
| 57 |
def to_pylist(self) -> list[Any]: ... |
| 58 |
def fill_null(self: A, fill_value: Any) -> A: ... |
| 59 |
|
| 60 |
class Array(_PandasConvertible): ... |
| 61 |
class ChunkedArray(_PandasConvertible): ... |
| 62 |
|
| 63 |
class StructArray(Array): |
| 64 |
def flatten(self, memory_pool: MemoryPool | None = None) -> list[Array]: ... |
| 65 |
|
| 66 |
T = TypeVar("T", bound="_Tabular") |
| 67 |
|
| 68 |
class _Tabular: |
| 69 |
@classmethod |
| 70 |
def from_arrays( |
| 71 |
cls: Type[T], |
| 72 |
arrays: list[_PandasConvertible], |
| 73 |
names: list[str] | None = None, |
| 74 |
schema: Schema | None = None, |
| 75 |
metadata: Mapping | None = None, |
| 76 |
) -> T: ... |
| 77 |
@classmethod |
| 78 |
def from_pydict( |
| 79 |
cls: Type[T], |
| 80 |
mapping: Mapping, |
| 81 |
schema: Schema | None = None, |
| 82 |
metadata: Mapping | None = None, |
| 83 |
) -> T: ... |
| 84 |
def __getitem__(self, index: int) -> _PandasConvertible: ... |
| 85 |
def __len__(self) -> int: ... |
| 86 |
@property |
| 87 |
def column_names(self) -> list[str]: ... |
| 88 |
@property |
| 89 |
def columns(self) -> list[_PandasConvertible]: ... |
| 90 |
@property |
| 91 |
def num_rows(self) -> int: ... |
| 92 |
@property |
| 93 |
def num_columns(self) -> int: ... |
| 94 |
@property |
| 95 |
def schema(self) -> Schema: ... |
| 96 |
def append_column( |
| 97 |
self: T, field_: str | Field, column: Array | ChunkedArray |
| 98 |
) -> T: ... |
| 99 |
def column(self, i: int | str) -> _PandasConvertible: ... |
| 100 |
def equals(self: T, other: T, check_metadata: bool = False) -> bool: ... |
| 101 |
def itercolumns(self) -> Iterator[_PandasConvertible]: ... |
| 102 |
def rename_columns(self: T, names: list[str]) -> T: ... |
| 103 |
def select(self: T, columns: Sequence[str | int]) -> T: ... |
| 104 |
def set_column( |
| 105 |
self: T, i: int, field_: str | Field, column: Array | ChunkedArray |
| 106 |
) -> T: ... |
| 107 |
def slice( # noqa: A003 |
| 108 |
self: T, |
| 109 |
offset: int = 0, |
| 110 |
length: int | None = None, |
| 111 |
) -> T: ... |
| 112 |
def sort_by( |
| 113 |
self: T, |
| 114 |
sorting: str | list[tuple[str, Literal["ascending", "descending"]]], |
| 115 |
**kwargs: Any, |
| 116 |
) -> T: ... |
| 117 |
def to_pylist(self) -> list[dict[str, Any]]: ... |
| 118 |
def to_pydict(self) -> dict[str, list[Any]]: ... |
| 119 |
|
| 120 |
class RecordBatch(_Tabular): ... |
| 121 |
|
| 122 |
class Table(_Tabular): |
| 123 |
@classmethod |
| 124 |
def from_batches( |
| 125 |
cls, |
| 126 |
batches: Iterable[RecordBatch], |
| 127 |
schema: Schema | None = None, |
| 128 |
) -> "Table": ... |
| 129 |
def to_batches(self) -> list[RecordBatch]: ... |
| 130 |
|
| 131 |
def array( |
| 132 |
obj: Iterable, |
| 133 |
type: DataType | None = None, # noqa: A002 |
| 134 |
mask: Array | None = None, |
| 135 |
size: int | None = None, |
| 136 |
from_pandas: bool | None = None, |
| 137 |
safe: bool = True, |
| 138 |
memory_pool: MemoryPool | None = None, |
| 139 |
) -> Array | ChunkedArray: ... |
| 140 |
def concat_arrays( |
| 141 |
arrays: Iterable[Array], memory_pool: MemoryPool | None = None |
| 142 |
) -> Array: ... |
| 143 |
def nulls( |
| 144 |
size: int, |
| 145 |
type: DataType | None = None, # noqa: A002 |
| 146 |
memory_pool: MemoryPool | None = None, |
| 147 |
) -> Array: ... |
| 148 |
def table( |
| 149 |
# pyarrow also accepts a pandas DataFrame here; Harlequin never builds one, |
| 150 |
# and typing it would put pandas-stubs in the static group for one name. |
| 151 |
data: Mapping[str, _PandasConvertible | list] | list[_PandasConvertible], |
| 152 |
names: list[str] | None = None, |
| 153 |
schema: Schema | None = None, |
| 154 |
metadata: Mapping | None = None, |
| 155 |
nthreads: int | None = None, |
| 156 |
) -> Table: ... |
| 157 |
def set_timezone_db_path(path: str) -> None: ... |