1
- __all__ = ["DataFrame" ]
2
-
3
- from typing import Sequence , TYPE_CHECKING
1
+ from __future__ import annotations
2
+ from typing import Sequence , Union , TYPE_CHECKING
4
3
5
4
if TYPE_CHECKING :
6
5
from .column_object import Column
7
6
from .groupby_object import GroupBy
7
+ from ._types import Scalar
8
+
9
+
10
+ __all__ = ["DataFrame" ]
8
11
9
12
10
13
class DataFrame :
@@ -33,7 +36,7 @@ def get_column_by_name(self, name: str, /) -> Column:
33
36
"""
34
37
...
35
38
36
- def get_columns_by_name (self , names : Sequence [str ], / ) -> " DataFrame" :
39
+ def get_columns_by_name (self , names : Sequence [str ], / ) -> DataFrame :
37
40
"""
38
41
Select multiple columns by name.
39
42
@@ -52,7 +55,7 @@ def get_columns_by_name(self, names: Sequence[str], /) -> "DataFrame":
52
55
"""
53
56
...
54
57
55
- def get_rows (self , indices : Sequence [int ]) -> " DataFrame" :
58
+ def get_rows (self , indices : Sequence [int ]) -> DataFrame :
56
59
"""
57
60
Select a subset of rows, similar to `ndarray.take`.
58
61
@@ -75,7 +78,7 @@ def get_rows(self, indices: Sequence[int]) -> "DataFrame":
75
78
76
79
def slice_rows (
77
80
self , start : int | None , stop : int | None , step : int | None
78
- ) -> " DataFrame" :
81
+ ) -> DataFrame :
79
82
"""
80
83
Select a subset of rows corresponding to a slice.
81
84
@@ -91,7 +94,7 @@ def slice_rows(
91
94
"""
92
95
...
93
96
94
- def get_rows_by_mask (self , mask : Column [bool ]) -> " DataFrame" :
97
+ def get_rows_by_mask (self , mask : " Column[bool]" ) -> DataFrame :
95
98
"""
96
99
Select a subset of rows corresponding to a mask.
97
100
@@ -110,7 +113,7 @@ def get_rows_by_mask(self, mask: Column[bool]) -> "DataFrame":
110
113
"""
111
114
...
112
115
113
- def insert (self , loc : int , label : str , value : Column ) -> " DataFrame" :
116
+ def insert (self , loc : int , label : str , value : Column ) -> DataFrame :
114
117
"""
115
118
Insert column into DataFrame at specified location.
116
119
@@ -124,7 +127,7 @@ def insert(self, loc: int, label: str, value: Column) -> "DataFrame":
124
127
"""
125
128
...
126
129
127
- def drop_column (self , label : str ) -> " DataFrame" :
130
+ def drop_column (self , label : str ) -> DataFrame :
128
131
"""
129
132
Drop the specified column.
130
133
@@ -143,7 +146,7 @@ def drop_column(self, label: str) -> "DataFrame":
143
146
"""
144
147
...
145
148
146
- def set_column (self , label : str , value : Column ) -> " DataFrame" :
149
+ def set_column (self , label : str , value : Column ) -> DataFrame :
147
150
"""
148
151
Add or replace a column.
149
152
@@ -158,8 +161,10 @@ def set_column(self, label: str, value: Column) -> "DataFrame":
158
161
"""
159
162
...
160
163
161
- def __eq__ (self , other : DataFrame | " Scalar" ) -> " DataFrame" :
164
+ def __eq__ (self , other : DataFrame | Scalar ) -> DataFrame :
162
165
"""
166
+ Compare for equality.
167
+
163
168
Parameters
164
169
----------
165
170
other : DataFrame or Scalar
@@ -173,8 +178,10 @@ def __eq__(self, other: DataFrame | "Scalar") -> "DataFrame":
173
178
"""
174
179
...
175
180
176
- def __ne__ (self , other : DataFrame | " Scalar" ) -> " DataFrame" :
181
+ def __ne__ (self , other : DataFrame | Scalar ) -> DataFrame :
177
182
"""
183
+ Compare for non-equality.
184
+
178
185
Parameters
179
186
----------
180
187
other : DataFrame or Scalar
@@ -188,8 +195,10 @@ def __ne__(self, other: DataFrame | "Scalar") -> "DataFrame":
188
195
"""
189
196
...
190
197
191
- def __ge__ (self , other : DataFrame | " Scalar" ) -> " DataFrame" :
198
+ def __ge__ (self , other : DataFrame | Scalar ) -> DataFrame :
192
199
"""
200
+ Compare for "greater than or equal to" `other`.
201
+
193
202
Parameters
194
203
----------
195
204
other : DataFrame or Scalar
@@ -203,8 +212,10 @@ def __ge__(self, other: DataFrame | "Scalar") -> "DataFrame":
203
212
"""
204
213
...
205
214
206
- def __gt__ (self , other : DataFrame | " Scalar" ) -> " DataFrame" :
215
+ def __gt__ (self , other : DataFrame | Scalar ) -> DataFrame :
207
216
"""
217
+ Compare for "greater than" `other`.
218
+
208
219
Parameters
209
220
----------
210
221
other : DataFrame or Scalar
@@ -218,8 +229,10 @@ def __gt__(self, other: DataFrame | "Scalar") -> "DataFrame":
218
229
"""
219
230
...
220
231
221
- def __le__ (self , other : DataFrame | " Scalar" ) -> " DataFrame" :
232
+ def __le__ (self , other : DataFrame | Scalar ) -> DataFrame :
222
233
"""
234
+ Compare for "less than or equal to" `other`.
235
+
223
236
Parameters
224
237
----------
225
238
other : DataFrame or Scalar
@@ -233,8 +246,10 @@ def __le__(self, other: DataFrame | "Scalar") -> "DataFrame":
233
246
"""
234
247
...
235
248
236
- def __lt__ (self , other : DataFrame | " Scalar" ) -> " DataFrame" :
249
+ def __lt__ (self , other : DataFrame | Scalar ) -> DataFrame :
237
250
"""
251
+ Compare for "less than" `other`.
252
+
238
253
Parameters
239
254
----------
240
255
other : DataFrame or Scalar
@@ -248,8 +263,10 @@ def __lt__(self, other: DataFrame | "Scalar") -> "DataFrame":
248
263
"""
249
264
...
250
265
251
- def __add__ (self , other : DataFrame | " Scalar" ) -> " DataFrame" :
266
+ def __add__ (self , other : DataFrame | Scalar ) -> DataFrame :
252
267
"""
268
+ Add `other` dataframe or scalar to this dataframe.
269
+
253
270
Parameters
254
271
----------
255
272
other : DataFrame or Scalar
@@ -263,8 +280,10 @@ def __add__(self, other: DataFrame | "Scalar") -> "DataFrame":
263
280
"""
264
281
...
265
282
266
- def __sub__ (self , other : DataFrame | " Scalar" ) -> " DataFrame" :
283
+ def __sub__ (self , other : DataFrame | Scalar ) -> DataFrame :
267
284
"""
285
+ Subtract `other` dataframe or scalar from this dataframe.
286
+
268
287
Parameters
269
288
----------
270
289
other : DataFrame or Scalar
@@ -278,8 +297,10 @@ def __sub__(self, other: DataFrame | "Scalar") -> "DataFrame":
278
297
"""
279
298
...
280
299
281
- def __mul__ (self , other : DataFrame | " Scalar" ) -> " DataFrame" :
300
+ def __mul__ (self , other : DataFrame | Scalar ) -> DataFrame :
282
301
"""
302
+ Multiply `other` dataframe or scalar with this dataframe.
303
+
283
304
Parameters
284
305
----------
285
306
other : DataFrame or Scalar
@@ -293,8 +314,10 @@ def __mul__(self, other: DataFrame | "Scalar") -> "DataFrame":
293
314
"""
294
315
...
295
316
296
- def __truediv__ (self , other : DataFrame | " Scalar" ) -> " DataFrame" :
317
+ def __truediv__ (self , other : DataFrame | Scalar ) -> DataFrame :
297
318
"""
319
+ Divide this dataframe by `other` dataframe or scalar. True division, returns floats.
320
+
298
321
Parameters
299
322
----------
300
323
other : DataFrame or Scalar
@@ -308,8 +331,10 @@ def __truediv__(self, other: DataFrame | "Scalar") -> "DataFrame":
308
331
"""
309
332
...
310
333
311
- def __floordiv__ (self , other : DataFrame | " Scalar" ) -> " DataFrame" :
334
+ def __floordiv__ (self , other : DataFrame | Scalar ) -> DataFrame :
312
335
"""
336
+ Floor-divide (returns integers) this dataframe by `other` dataframe or scalar.
337
+
313
338
Parameters
314
339
----------
315
340
other : DataFrame or Scalar
@@ -323,8 +348,10 @@ def __floordiv__(self, other: DataFrame | "Scalar") -> "DataFrame":
323
348
"""
324
349
...
325
350
326
- def __pow__ (self , other : DataFrame | " Scalar" ) -> " DataFrame" :
351
+ def __pow__ (self , other : DataFrame | Scalar ) -> DataFrame :
327
352
"""
353
+ Raise this dataframe to the power of `other`.
354
+
328
355
Parameters
329
356
----------
330
357
other : DataFrame or Scalar
@@ -338,8 +365,10 @@ def __pow__(self, other: DataFrame | "Scalar") -> "DataFrame":
338
365
"""
339
366
...
340
367
341
- def __mod__ (self , other : DataFrame | " Scalar" ) -> " DataFrame" :
368
+ def __mod__ (self , other : DataFrame | Scalar ) -> DataFrame :
342
369
"""
370
+ Return modulus of this dataframe by `other` (`%` operator).
371
+
343
372
Parameters
344
373
----------
345
374
other : DataFrame or Scalar
@@ -353,8 +382,10 @@ def __mod__(self, other: DataFrame | "Scalar") -> "DataFrame":
353
382
"""
354
383
...
355
384
356
- def __divmod__ (self , other : DataFrame | " Scalar" ) -> tuple [" DataFrame" , " DataFrame" ]:
385
+ def __divmod__ (self , other : DataFrame | Scalar ) -> tuple [DataFrame , DataFrame ]:
357
386
"""
387
+ Return quotient and remainder of integer division. See `divmod` builtin function.
388
+
358
389
Parameters
359
390
----------
360
391
other : DataFrame or Scalar
@@ -364,8 +395,7 @@ def __divmod__(self, other: DataFrame | "Scalar") -> tuple["DataFrame", "DataFra
364
395
365
396
Returns
366
397
-------
367
- DataFrame
368
- DataFrame
398
+ A tuple of two DataFrame's
369
399
"""
370
400
...
371
401
0 commit comments