|
1 | 1 | from __future__ import annotations
|
2 |
| -from typing import Sequence, Union, TYPE_CHECKING, NoReturn |
| 2 | +from typing import Sequence, Union, TYPE_CHECKING, NoReturn, Mapping |
3 | 3 |
|
4 | 4 | if TYPE_CHECKING:
|
5 | 5 | from .column_object import Column
|
@@ -34,6 +34,24 @@ class DataFrame:
|
34 | 34 | **Methods and Attributes**
|
35 | 35 |
|
36 | 36 | """
|
| 37 | + |
| 38 | + @classmethod |
| 39 | + def from_dict(cls, data: Mapping[str, Column]) -> DataFrame: |
| 40 | + """ |
| 41 | + Construct DataFrame from map of column names to Columns. |
| 42 | +
|
| 43 | + Parameters |
| 44 | + ---------- |
| 45 | + data : Mapping[str, Column] |
| 46 | + Column must be of the corresponding type of the DataFrame. |
| 47 | + For example, it is only supported to build a ``LibraryXDataFrame`` using |
| 48 | + ``LibraryXColumn`` instances. |
| 49 | +
|
| 50 | + Returns |
| 51 | + ------- |
| 52 | + DataFrame |
| 53 | + """ |
| 54 | + |
37 | 55 | @property
|
38 | 56 | def dataframe(self) -> object:
|
39 | 57 | """
|
@@ -111,24 +129,18 @@ def get_columns_by_name(self, names: Sequence[str], /) -> DataFrame:
|
111 | 129 | """
|
112 | 130 | ...
|
113 | 131 |
|
114 |
| - def get_rows(self, indices: Sequence[int]) -> DataFrame: |
| 132 | + def get_rows(self, indices: "Column[int]") -> DataFrame: |
115 | 133 | """
|
116 | 134 | Select a subset of rows, similar to `ndarray.take`.
|
117 | 135 |
|
118 | 136 | Parameters
|
119 | 137 | ----------
|
120 |
| - indices : Sequence[int] |
| 138 | + indices : Column[int] |
121 | 139 | Positions of rows to select.
|
122 | 140 |
|
123 | 141 | Returns
|
124 | 142 | -------
|
125 | 143 | DataFrame
|
126 |
| -
|
127 |
| - Notes |
128 |
| - ----- |
129 |
| - Some discussion participants prefer a stricter type Column[int] for |
130 |
| - indices in order to make it easier to implement in a performant manner |
131 |
| - on GPUs. |
132 | 144 | """
|
133 | 145 | ...
|
134 | 146 |
|
|
0 commit comments