From 647a3939c89f236033c06afe120c8e879bf1f853 Mon Sep 17 00:00:00 2001 From: Brock Date: Sat, 20 Mar 2021 10:26:16 -0700 Subject: [PATCH 1/3] DOC: suppress warnings from CategoricalBlock deprecation --- doc/source/user_guide/io.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/source/user_guide/io.rst b/doc/source/user_guide/io.rst index cf153ddd2cbbd..3b7a6037a9715 100644 --- a/doc/source/user_guide/io.rst +++ b/doc/source/user_guide/io.rst @@ -5240,6 +5240,7 @@ Write to a feather file. Read from a feather file. .. ipython:: python + :okwarning: result = pd.read_feather("example.feather") result @@ -5323,6 +5324,7 @@ Write to a parquet file. Read from a parquet file. .. ipython:: python + :okwarning: result = pd.read_parquet("example_fp.parquet", engine="fastparquet") result = pd.read_parquet("example_pa.parquet", engine="pyarrow") From 08f63684cfb749dd0e03558c42b03c57141f87dd Mon Sep 17 00:00:00 2001 From: Brock Date: Sat, 20 Mar 2021 21:05:52 -0700 Subject: [PATCH 2/3] TYP: internals.pyi --- pandas/_libs/internals.pyi | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 pandas/_libs/internals.pyi diff --git a/pandas/_libs/internals.pyi b/pandas/_libs/internals.pyi new file mode 100644 index 0000000000000..f31334b1f8935 --- /dev/null +++ b/pandas/_libs/internals.pyi @@ -0,0 +1,48 @@ +from typing import ( + Iterator, + Sequence, + overload, +) + +import numpy as np + +def slice_len(slc: slice, objlen: int = ...) -> int: ... + + +def get_blkno_indexers( + blknos: np.ndarray, # int64_t[:] + group: bool = ..., +) -> list[tuple[int, slice | np.ndarray]]: ... + + +def get_blkno_placements( + blknos: np.ndarray, + group: bool = ..., +) -> Iterator[tuple[int, BlockPlacement]]: ... + + +class BlockPlacement: + def __init__(self, val: int | slice | np.ndarray): ... + + @property + def indexer(self) -> np.ndarray | slice: ... + + @property + def as_array(self) -> np.ndarray: ... + + @property + def is_slice_like(self) -> bool: ... + + @overload + def __getitem__(self, loc: slice | Sequence[int]) -> BlockPlacement: ... + + @overload + def __getitem__(self, loc: int) -> int: ... + + def __iter__(self) -> Iterator[int]: ... + + def __len__(self) -> int: ... + + def delete(self, loc) -> BlockPlacement: ... + + def append(self, others: list[BlockPlacement]) -> BlockPlacement: ... From 1fbea04acf66bed628bbed46a4ef5d5b0ba3830b Mon Sep 17 00:00:00 2001 From: Brock Date: Fri, 26 Mar 2021 16:15:57 -0700 Subject: [PATCH 3/3] add Block to internals.pyi --- pandas/_libs/internals.pyi | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pandas/_libs/internals.pyi b/pandas/_libs/internals.pyi index f31334b1f8935..446ee299698c5 100644 --- a/pandas/_libs/internals.pyi +++ b/pandas/_libs/internals.pyi @@ -6,6 +6,8 @@ from typing import ( import numpy as np +from pandas._typing import ArrayLike + def slice_len(slc: slice, objlen: int = ...) -> int: ... @@ -46,3 +48,11 @@ class BlockPlacement: def delete(self, loc) -> BlockPlacement: ... def append(self, others: list[BlockPlacement]) -> BlockPlacement: ... + + +class Block: + _mgr_locs: BlockPlacement + ndim: int + values: ArrayLike + + def __init__(self, values: ArrayLike, placement: BlockPlacement, ndim: int): ...