Skip to content

Commit 6ed91b4

Browse files
jbrockmendelrgommers
authored andcommitted
Add API methods
1 parent 8d05ee8 commit 6ed91b4

File tree

2 files changed

+336
-1
lines changed

2 files changed

+336
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Column:
2+
pass
Lines changed: 334 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,338 @@
11
__all__ = ["DataFrame"]
22

3+
from typing import Sequence, TYPE_CHECKING
4+
5+
if TYPE_CHECKING:
6+
from .column_object import Column
7+
38

49
class DataFrame:
5-
pass
10+
11+
def get_column_by_name(self, key: str) -> Column:
12+
"""
13+
Select a column by name.
14+
15+
Parameters
16+
----------
17+
key : str
18+
19+
Returns
20+
-------
21+
Column
22+
23+
Raises
24+
------
25+
KeyError
26+
If the key is not present.
27+
"""
28+
...
29+
30+
def get_columns_by_name(self, keys: Sequence[str]) -> DataFrame:
31+
"""
32+
Select multiple columns by name.
33+
34+
Parameters
35+
----------
36+
keys : Sequence[str]
37+
38+
Returns
39+
-------
40+
DataFrame
41+
42+
Raises
43+
------
44+
KeyError
45+
If the any requested key is not present.
46+
"""
47+
...
48+
49+
def get_rows(self, indices: Sequence[int]) -> DataFrame:
50+
"""
51+
Select a subset of rows, similar to `ndarray.take`.
52+
53+
Parameters
54+
----------
55+
indices : Sequence[int]
56+
Positions of rows to select.
57+
58+
Returns
59+
-------
60+
DataFrame
61+
62+
Notes
63+
-----
64+
Some discussion participants prefer a stricter type Column[int] for
65+
indices.
66+
"""
67+
...
68+
69+
def slice_rows(
70+
self, start: int | None, stop: int | None, step: int | None
71+
) -> DataFrame:
72+
"""
73+
Select a subset of rows corresponding to a slice.
74+
75+
Parameters
76+
----------
77+
start : int or None
78+
stop : int or None
79+
step : int or None
80+
81+
Returns
82+
-------
83+
DataFrame
84+
"""
85+
...
86+
87+
def get_rows_by_mask(self, mask: Column[bool]) -> DataFrame:
88+
"""
89+
Select a subset of rows corresponding to a mask.
90+
91+
Parameters
92+
----------
93+
mask : Column[bool]
94+
95+
Returns
96+
-------
97+
DataFrame
98+
99+
Notes
100+
-----
101+
Some participants preferred a weaker type Arraylike[bool] for mask,
102+
where 'Arraylike' denotes an object adhering to the Array API standard.
103+
"""
104+
...
105+
106+
def insert(self, loc: int, label: str, value: Column) -> DataFrame:
107+
...
108+
109+
def drop_column(self, label: str) -> DataFrame:
110+
"""
111+
Drop the specified column.
112+
113+
Parameters
114+
----------
115+
label : str
116+
117+
Returns
118+
-------
119+
DataFrame
120+
121+
Raises
122+
------
123+
KeyError
124+
If the label is not present.
125+
"""
126+
...
127+
128+
def set_column(self, label: str, value: Column) -> DataFrame:
129+
"""
130+
Add or replace a column.
131+
132+
Parameters
133+
----------
134+
label : str
135+
value : Column
136+
137+
Returns
138+
-------
139+
DataFrame
140+
"""
141+
...
142+
143+
def __eq__(self, other: DataFrame | "Scalar") -> DataFrame:
144+
"""
145+
Parameters
146+
----------
147+
other : DataFrame or Scalar
148+
If DataFrame, must have same length and matching columns.
149+
"Scalar" here is defined implicitly by the contained dtypes.
150+
151+
Returns
152+
-------
153+
DataFrame
154+
"""
155+
...
156+
157+
def __ne__(self, other: DataFrame | "Scalar") -> DataFrame:
158+
"""
159+
Parameters
160+
----------
161+
other : DataFrame or Scalar
162+
If DataFrame, must have same length and matching columns.
163+
"Scalar" here is defined implicitly by the contained dtypes.
164+
165+
Returns
166+
-------
167+
DataFrame
168+
"""
169+
...
170+
171+
def __ge__(self, other: DataFrame | "Scalar") -> DataFrame:
172+
"""
173+
Parameters
174+
----------
175+
other : DataFrame or Scalar
176+
If DataFrame, must have same length and matching columns.
177+
"Scalar" here is defined implicitly by the contained dtypes.
178+
179+
Returns
180+
-------
181+
DataFrame
182+
"""
183+
...
184+
185+
def __gt__(self, other: DataFrame | "Scalar") -> DataFrame:
186+
"""
187+
Parameters
188+
----------
189+
other : DataFrame or Scalar
190+
If DataFrame, must have same length and matching columns.
191+
"Scalar" here is defined implicitly by the contained dtypes.
192+
193+
Returns
194+
-------
195+
DataFrame
196+
"""
197+
...
198+
199+
def __le__(self, other: DataFrame | "Scalar") -> DataFrame:
200+
"""
201+
Parameters
202+
----------
203+
other : DataFrame or Scalar
204+
If DataFrame, must have same length and matching columns.
205+
"Scalar" here is defined implicitly by the contained dtypes.
206+
207+
Returns
208+
-------
209+
DataFrame
210+
"""
211+
...
212+
213+
def __lt__(self, other: DataFrame | "Scalar") -> DataFrame:
214+
"""
215+
Parameters
216+
----------
217+
other : DataFrame or Scalar
218+
If DataFrame, must have same length and matching columns.
219+
"Scalar" here is defined implicitly by the contained dtypes.
220+
221+
Returns
222+
-------
223+
DataFrame
224+
"""
225+
...
226+
227+
def __add__(self, other: DataFrame | "Scalar") -> DataFrame:
228+
"""
229+
Parameters
230+
----------
231+
other : DataFrame or Scalar
232+
If DataFrame, must have same length and matching columns.
233+
"Scalar" here is defined implicitly by the contained dtypes.
234+
235+
Returns
236+
-------
237+
DataFrame
238+
"""
239+
...
240+
241+
def __sub__(self, other: DataFrame | "Scalar") -> DataFrame:
242+
"""
243+
Parameters
244+
----------
245+
other : DataFrame or Scalar
246+
If DataFrame, must have same length and matching columns.
247+
"Scalar" here is defined implicitly by the contained dtypes.
248+
249+
Returns
250+
-------
251+
DataFrame
252+
"""
253+
...
254+
255+
def __mul__(self, other: DataFrame | "Scalar") -> DataFrame:
256+
"""
257+
Parameters
258+
----------
259+
other : DataFrame or Scalar
260+
If DataFrame, must have same length and matching columns.
261+
"Scalar" here is defined implicitly by the contained dtypes.
262+
263+
Returns
264+
-------
265+
DataFrame
266+
"""
267+
...
268+
269+
def __truediv__(self, other: DataFrame | "Scalar") -> DataFrame:
270+
"""
271+
Parameters
272+
----------
273+
other : DataFrame or Scalar
274+
If DataFrame, must have same length and matching columns.
275+
"Scalar" here is defined implicitly by the contained dtypes.
276+
277+
Returns
278+
-------
279+
DataFrame
280+
"""
281+
...
282+
283+
def __floordiv__(self, other: DataFrame | "Scalar") -> DataFrame:
284+
"""
285+
Parameters
286+
----------
287+
other : DataFrame or Scalar
288+
If DataFrame, must have same length and matching columns.
289+
"Scalar" here is defined implicitly by the contained dtypes.
290+
291+
Returns
292+
-------
293+
DataFrame
294+
"""
295+
...
296+
297+
def __pow__(self, other: DataFrame | "Scalar") -> DataFrame:
298+
"""
299+
Parameters
300+
----------
301+
other : DataFrame or Scalar
302+
If DataFrame, must have same length and matching columns.
303+
"Scalar" here is defined implicitly by the contained dtypes.
304+
305+
Returns
306+
-------
307+
DataFrame
308+
"""
309+
...
310+
311+
def __mod__(self, other: DataFrame | "Scalar") -> DataFrame:
312+
"""
313+
Parameters
314+
----------
315+
other : DataFrame or Scalar
316+
If DataFrame, must have same length and matching columns.
317+
"Scalar" here is defined implicitly by the contained dtypes.
318+
319+
Returns
320+
-------
321+
DataFrame
322+
"""
323+
...
324+
325+
def __divmod__(self, other: DataFrame | "Scalar") -> tuple[DataFrame, DataFrame]:
326+
"""
327+
Parameters
328+
----------
329+
other : DataFrame or Scalar
330+
If DataFrame, must have same length and matching columns.
331+
"Scalar" here is defined implicitly by the contained dtypes.
332+
333+
Returns
334+
-------
335+
DataFrame
336+
DataFrame
337+
"""
338+
...

0 commit comments

Comments
 (0)