Skip to content

Commit a03549d

Browse files
committed
suggested edits
1 parent 7fcc078 commit a03549d

File tree

1 file changed

+65
-39
lines changed

1 file changed

+65
-39
lines changed

spec/API_specification/dataframe_api/dataframe_object.py

Lines changed: 65 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99
class DataFrame:
1010

11-
def get_column_by_name(self, key: str) -> Column:
11+
def get_column_by_name(self, name: str) -> Column:
1212
"""
1313
Select a column by name.
1414
1515
Parameters
1616
----------
17-
key : str
17+
name : str
1818
1919
Returns
2020
-------
@@ -27,13 +27,13 @@ def get_column_by_name(self, key: str) -> Column:
2727
"""
2828
...
2929

30-
def get_columns_by_name(self, keys: Sequence[str]) -> DataFrame:
30+
def get_columns_by_name(self, names: Sequence[str]) -> "DataFrame":
3131
"""
3232
Select multiple columns by name.
3333
3434
Parameters
3535
----------
36-
keys : Sequence[str]
36+
names : Sequence[str]
3737
3838
Returns
3939
-------
@@ -46,7 +46,7 @@ def get_columns_by_name(self, keys: Sequence[str]) -> DataFrame:
4646
"""
4747
...
4848

49-
def get_rows(self, indices: Sequence[int]) -> DataFrame:
49+
def get_rows(self, indices: Sequence[int]) -> "DataFrame":
5050
"""
5151
Select a subset of rows, similar to `ndarray.take`.
5252
@@ -62,13 +62,14 @@ def get_rows(self, indices: Sequence[int]) -> DataFrame:
6262
Notes
6363
-----
6464
Some discussion participants prefer a stricter type Column[int] for
65-
indices.
65+
indices in order to make it easier to implement in a performant manner
66+
on GPUs.
6667
"""
6768
...
6869

6970
def slice_rows(
7071
self, start: int | None, stop: int | None, step: int | None
71-
) -> DataFrame:
72+
) -> "DataFrame":
7273
"""
7374
Select a subset of rows corresponding to a slice.
7475
@@ -84,7 +85,7 @@ def slice_rows(
8485
"""
8586
...
8687

87-
def get_rows_by_mask(self, mask: Column[bool]) -> DataFrame:
88+
def get_rows_by_mask(self, mask: Column[bool]) -> "DataFrame":
8889
"""
8990
Select a subset of rows corresponding to a mask.
9091
@@ -103,10 +104,21 @@ def get_rows_by_mask(self, mask: Column[bool]) -> DataFrame:
103104
"""
104105
...
105106

106-
def insert(self, loc: int, label: str, value: Column) -> DataFrame:
107+
def insert(self, loc: int, label: str, value: Column) -> "DataFrame":
108+
"""
109+
Insert column into DataFrame at specified location.
110+
111+
Parameters
112+
----------
113+
loc : int
114+
Insertion index. Must verify 0 <= loc <= len(columns).
115+
label : str
116+
Label of the inserted column.
117+
value : Column
118+
"""
107119
...
108120

109-
def drop_column(self, label: str) -> DataFrame:
121+
def drop_column(self, label: str) -> "DataFrame":
110122
"""
111123
Drop the specified column.
112124
@@ -125,7 +137,7 @@ def drop_column(self, label: str) -> DataFrame:
125137
"""
126138
...
127139

128-
def set_column(self, label: str, value: Column) -> DataFrame:
140+
def set_column(self, label: str, value: Column) -> "DataFrame":
129141
"""
130142
Add or replace a column.
131143
@@ -140,195 +152,209 @@ def set_column(self, label: str, value: Column) -> DataFrame:
140152
"""
141153
...
142154

143-
def __eq__(self, other: DataFrame | "Scalar") -> DataFrame:
155+
def __eq__(self, other: DataFrame | "Scalar") -> "DataFrame":
144156
"""
145157
Parameters
146158
----------
147159
other : DataFrame or Scalar
148160
If DataFrame, must have same length and matching columns.
149-
"Scalar" here is defined implicitly by the contained dtypes.
161+
"Scalar" here is defined implicitly by what scalar types are allowed
162+
for the operation by the underling dtypes.
150163
151164
Returns
152165
-------
153166
DataFrame
154167
"""
155168
...
156169

157-
def __ne__(self, other: DataFrame | "Scalar") -> DataFrame:
170+
def __ne__(self, other: DataFrame | "Scalar") -> "DataFrame":
158171
"""
159172
Parameters
160173
----------
161174
other : DataFrame or Scalar
162175
If DataFrame, must have same length and matching columns.
163-
"Scalar" here is defined implicitly by the contained dtypes.
176+
"Scalar" here is defined implicitly by what scalar types are allowed
177+
for the operation by the underling dtypes.
164178
165179
Returns
166180
-------
167181
DataFrame
168182
"""
169183
...
170184

171-
def __ge__(self, other: DataFrame | "Scalar") -> DataFrame:
185+
def __ge__(self, other: DataFrame | "Scalar") -> "DataFrame":
172186
"""
173187
Parameters
174188
----------
175189
other : DataFrame or Scalar
176190
If DataFrame, must have same length and matching columns.
177-
"Scalar" here is defined implicitly by the contained dtypes.
191+
"Scalar" here is defined implicitly by what scalar types are allowed
192+
for the operation by the underling dtypes.
178193
179194
Returns
180195
-------
181196
DataFrame
182197
"""
183198
...
184199

185-
def __gt__(self, other: DataFrame | "Scalar") -> DataFrame:
200+
def __gt__(self, other: DataFrame | "Scalar") -> "DataFrame":
186201
"""
187202
Parameters
188203
----------
189204
other : DataFrame or Scalar
190205
If DataFrame, must have same length and matching columns.
191-
"Scalar" here is defined implicitly by the contained dtypes.
206+
"Scalar" here is defined implicitly by what scalar types are allowed
207+
for the operation by the underling dtypes.
192208
193209
Returns
194210
-------
195211
DataFrame
196212
"""
197213
...
198214

199-
def __le__(self, other: DataFrame | "Scalar") -> DataFrame:
215+
def __le__(self, other: DataFrame | "Scalar") -> "DataFrame":
200216
"""
201217
Parameters
202218
----------
203219
other : DataFrame or Scalar
204220
If DataFrame, must have same length and matching columns.
205-
"Scalar" here is defined implicitly by the contained dtypes.
221+
"Scalar" here is defined implicitly by what scalar types are allowed
222+
for the operation by the underling dtypes.
206223
207224
Returns
208225
-------
209226
DataFrame
210227
"""
211228
...
212229

213-
def __lt__(self, other: DataFrame | "Scalar") -> DataFrame:
230+
def __lt__(self, other: DataFrame | "Scalar") -> "DataFrame":
214231
"""
215232
Parameters
216233
----------
217234
other : DataFrame or Scalar
218235
If DataFrame, must have same length and matching columns.
219-
"Scalar" here is defined implicitly by the contained dtypes.
236+
"Scalar" here is defined implicitly by what scalar types are allowed
237+
for the operation by the underling dtypes.
220238
221239
Returns
222240
-------
223241
DataFrame
224242
"""
225243
...
226244

227-
def __add__(self, other: DataFrame | "Scalar") -> DataFrame:
245+
def __add__(self, other: DataFrame | "Scalar") -> "DataFrame":
228246
"""
229247
Parameters
230248
----------
231249
other : DataFrame or Scalar
232250
If DataFrame, must have same length and matching columns.
233-
"Scalar" here is defined implicitly by the contained dtypes.
251+
"Scalar" here is defined implicitly by what scalar types are allowed
252+
for the operation by the underling dtypes.
234253
235254
Returns
236255
-------
237256
DataFrame
238257
"""
239258
...
240259

241-
def __sub__(self, other: DataFrame | "Scalar") -> DataFrame:
260+
def __sub__(self, other: DataFrame | "Scalar") -> "DataFrame":
242261
"""
243262
Parameters
244263
----------
245264
other : DataFrame or Scalar
246265
If DataFrame, must have same length and matching columns.
247-
"Scalar" here is defined implicitly by the contained dtypes.
266+
"Scalar" here is defined implicitly by what scalar types are allowed
267+
for the operation by the underling dtypes.
248268
249269
Returns
250270
-------
251271
DataFrame
252272
"""
253273
...
254274

255-
def __mul__(self, other: DataFrame | "Scalar") -> DataFrame:
275+
def __mul__(self, other: DataFrame | "Scalar") -> "DataFrame":
256276
"""
257277
Parameters
258278
----------
259279
other : DataFrame or Scalar
260280
If DataFrame, must have same length and matching columns.
261-
"Scalar" here is defined implicitly by the contained dtypes.
281+
"Scalar" here is defined implicitly by what scalar types are allowed
282+
for the operation by the underling dtypes.
262283
263284
Returns
264285
-------
265286
DataFrame
266287
"""
267288
...
268289

269-
def __truediv__(self, other: DataFrame | "Scalar") -> DataFrame:
290+
def __truediv__(self, other: DataFrame | "Scalar") -> "DataFrame":
270291
"""
271292
Parameters
272293
----------
273294
other : DataFrame or Scalar
274295
If DataFrame, must have same length and matching columns.
275-
"Scalar" here is defined implicitly by the contained dtypes.
296+
"Scalar" here is defined implicitly by what scalar types are allowed
297+
for the operation by the underling dtypes.
276298
277299
Returns
278300
-------
279301
DataFrame
280302
"""
281303
...
282304

283-
def __floordiv__(self, other: DataFrame | "Scalar") -> DataFrame:
305+
def __floordiv__(self, other: DataFrame | "Scalar") -> "DataFrame":
284306
"""
285307
Parameters
286308
----------
287309
other : DataFrame or Scalar
288310
If DataFrame, must have same length and matching columns.
289-
"Scalar" here is defined implicitly by the contained dtypes.
311+
"Scalar" here is defined implicitly by what scalar types are allowed
312+
for the operation by the underling dtypes.
290313
291314
Returns
292315
-------
293316
DataFrame
294317
"""
295318
...
296319

297-
def __pow__(self, other: DataFrame | "Scalar") -> DataFrame:
320+
def __pow__(self, other: DataFrame | "Scalar") -> "DataFrame":
298321
"""
299322
Parameters
300323
----------
301324
other : DataFrame or Scalar
302325
If DataFrame, must have same length and matching columns.
303-
"Scalar" here is defined implicitly by the contained dtypes.
326+
"Scalar" here is defined implicitly by what scalar types are allowed
327+
for the operation by the underling dtypes.
304328
305329
Returns
306330
-------
307331
DataFrame
308332
"""
309333
...
310334

311-
def __mod__(self, other: DataFrame | "Scalar") -> DataFrame:
335+
def __mod__(self, other: DataFrame | "Scalar") -> "DataFrame":
312336
"""
313337
Parameters
314338
----------
315339
other : DataFrame or Scalar
316340
If DataFrame, must have same length and matching columns.
317-
"Scalar" here is defined implicitly by the contained dtypes.
341+
"Scalar" here is defined implicitly by what scalar types are allowed
342+
for the operation by the underling dtypes.
318343
319344
Returns
320345
-------
321346
DataFrame
322347
"""
323348
...
324349

325-
def __divmod__(self, other: DataFrame | "Scalar") -> tuple[DataFrame, DataFrame]:
350+
def __divmod__(self, other: DataFrame | "Scalar") -> tuple["DataFrame", "DataFrame"]:
326351
"""
327352
Parameters
328353
----------
329354
other : DataFrame or Scalar
330355
If DataFrame, must have same length and matching columns.
331-
"Scalar" here is defined implicitly by the contained dtypes.
356+
"Scalar" here is defined implicitly by what scalar types are allowed
357+
for the operation by the underling dtypes.
332358
333359
Returns
334360
-------

0 commit comments

Comments
 (0)