daf.typing.frames¶
The types here describe 2D data inside a pandas.DataFrame
, where all the elements have the same data type, which can
be fetched from daf
storage.
Logically and operationally this is a distinct data type from a generic data frame where each column has a different
data type (that is, a “real” data frame). Since pandas
does not make this distinction, even if/when it will provide
mypy
annotations, we’d still need to set up the types here (similar to the problem with numpy.ndarray
).
Note
In theory it should have been possible to store sparse data inside a pandas.DataFrame
, but in practice this
fails in various ways, so don’t. When fetching data from daf
, frames will alway contain dense
(numpy.ndarray
2D) data.
Data:
A 2D |
|
|
|
Functions:
|
Check whether some |
|
Assert that some |
|
Check whether some |
|
Assert that some |
|
Check whether some |
|
Assert that some |
- daf.typing.frames.Frame(*args, **kwargs)¶
A 2D
pandas.DataFrame
with homogeneous data elements, in any-major layout.alias of
Union
[FrameInRows
,FrameInColumns
]
- daf.typing.frames.is_frame(data: Any, *, dtype: Optional[_dtypes.DTypes] = None, shape: Optional[Tuple[int, int]] = None, layout: Optional[_layouts.AnyMajor] = None) TypeGuard[Frame] [source]¶
Check whether some
data
is aFrame
, optionally only of somedtype
, optionally only of someshape
, optionally only of somelayout
.By default, checks that the data type is one of
ALL_DTYPES
.
- daf.typing.frames.be_frame(data: Any, *, dtype: Optional[Union[str, dtype, Collection[str], Collection[dtype], Collection[Union[str, dtype]]]] = None, shape: Optional[Tuple[int, int]] = None, layout: Optional[AnyMajor] = None) Union[FrameInRows, FrameInColumns] [source]¶
Assert that some
data
is aFrame
optionally only of somedtype
, optionally only of someshape
, optionally only of somelayout
, and return it as such formypy
.By default, checks that the data type is one of
ALL_DTYPES
.
- daf.typing.frames.FrameInRows¶
A 2D
pandas.DataFrame
with homogeneous data elements, in row-major layout.alias of
DataFrame
- daf.typing.frames.is_frame_in_rows(data: Any, *, dtype: Optional[_dtypes.DTypes] = None, shape: Optional[Tuple[int, int]] = None) TypeGuard[FrameInRows] [source]¶
Check whether some
data
is aFrameInRows
, optionally only of somedtype
, optionally only of someshape
.By default, checks that the data type is one of
ALL_DTYPES
.
- daf.typing.frames.be_frame_in_rows(data: Any, *, dtype: Optional[Union[str, dtype, Collection[str], Collection[dtype], Collection[Union[str, dtype]]]] = None, shape: Optional[Tuple[int, int]] = None) FrameInRows [source]¶
Assert that some
data
is aFrameInRows
, optionally only of somedtype
, optionally only of someshape
, and return it as such formypy
.By default, checks that the data type is one of
ALL_DTYPES
.
- daf.typing.frames.FrameInColumns¶
A 2D
pandas.DataFrame
with homogeneous data elements, in column-major layout.alias of
DataFrame
- daf.typing.frames.is_frame_in_columns(data: Any, *, dtype: Optional[_dtypes.DTypes] = None, shape: Optional[Tuple[int, int]] = None) TypeGuard[FrameInColumns] [source]¶
Check whether some
data
is aFrameInColumns
, optionally only of somedtype
, optionally only of someshape
.By default, checks that the data type is one of
ALL_DTYPES
.
- daf.typing.frames.be_frame_in_columns(data: Any, *, dtype: Optional[Union[str, dtype, Collection[str], Collection[dtype], Collection[Union[str, dtype]]]] = None, shape: Optional[Tuple[int, int]] = None) FrameInColumns [source]¶
Assert that some
data
is aFrameInColumns
, optionally only of somedtype
, optionally only of someshape
, and return it as such formypy
.By default, checks that the data type is one of
ALL_DTYPES
.