1
1
# mypy: disable-error-code="empty-body"
2
- """
3
- Function stubs and API documentation for the DataFrame API standard.
4
- """
2
+ """Function stubs and API documentation for the DataFrame API standard."""
5
3
from __future__ import annotations
6
4
7
- from typing import Dict , Sequence , Any , TYPE_CHECKING
5
+ from typing import TYPE_CHECKING , Any
8
6
9
- from .column_object import *
7
+ from .column_object import Column
10
8
from .dataframe_object import DataFrame
11
- from .groupby_object import *
12
- from .dtypes import *
9
+ from .dtypes import (
10
+ Bool ,
11
+ Date ,
12
+ Datetime ,
13
+ Duration ,
14
+ Float32 ,
15
+ Float64 ,
16
+ Int8 ,
17
+ Int16 ,
18
+ Int32 ,
19
+ Int64 ,
20
+ String ,
21
+ UInt8 ,
22
+ UInt16 ,
23
+ UInt32 ,
24
+ UInt64 ,
25
+ )
26
+ from .groupby_object import Aggregation , GroupBy
13
27
14
28
if TYPE_CHECKING :
29
+ from collections .abc import Sequence
30
+
15
31
from .typing import DType , Scalar
16
32
17
33
__all__ = [
34
+ "GroupBy" ,
18
35
"Aggregation" ,
19
36
"Bool" ,
20
- "Column" ,
21
- "DataFrame" ,
22
37
"Date" ,
23
38
"Datetime" ,
24
39
"Duration" ,
33
48
"UInt32" ,
34
49
"UInt64" ,
35
50
"UInt8" ,
51
+ "Column" ,
52
+ "DataFrame" ,
36
53
"__dataframe_api_version__" ,
37
54
"column_from_1d_array" ,
38
55
"column_from_sequence" ,
53
70
implementation of the dataframe API standard.
54
71
"""
55
72
73
+
56
74
def concat (dataframes : Sequence [DataFrame ]) -> DataFrame :
57
- """
58
- Concatenate DataFrames vertically.
75
+ """Concatenate DataFrames vertically.
59
76
60
77
Parameters
61
78
----------
@@ -71,9 +88,14 @@ def concat(dataframes: Sequence[DataFrame]) -> DataFrame:
71
88
"""
72
89
...
73
90
74
- def column_from_sequence (sequence : Sequence [Any ], * , dtype : DType , name : str = '' ) -> Column :
75
- """
76
- Construct Column from sequence of elements.
91
+
92
+ def column_from_sequence (
93
+ sequence : Sequence [Any ],
94
+ * ,
95
+ dtype : DType ,
96
+ name : str = "" ,
97
+ ) -> Column :
98
+ """Construct Column from sequence of elements.
77
99
78
100
Parameters
79
101
----------
@@ -92,9 +114,9 @@ def column_from_sequence(sequence: Sequence[Any], *, dtype: DType, name: str = '
92
114
"""
93
115
...
94
116
117
+
95
118
def dataframe_from_columns (* columns : Column ) -> DataFrame :
96
- """
97
- Construct DataFrame from sequence of Columns.
119
+ """Construct DataFrame from sequence of Columns.
98
120
99
121
Parameters
100
122
----------
@@ -110,9 +132,8 @@ def dataframe_from_columns(*columns: Column) -> DataFrame:
110
132
...
111
133
112
134
113
- def column_from_1d_array (array : Any , * , name : str = '' ) -> Column :
114
- """
115
- Construct Column from 1D array.
135
+ def column_from_1d_array (array : Any , * , name : str = "" ) -> Column :
136
+ """Construct Column from 1D array.
116
137
117
138
See `dataframe_from_2d_array` for related 2D function.
118
139
@@ -148,9 +169,9 @@ def column_from_1d_array(array: Any, *, name: str = '') -> Column:
148
169
"""
149
170
...
150
171
151
- def dataframe_from_2d_array ( array : Any , * , schema : Dict [ str , DType ]) -> DataFrame :
152
- """
153
- Construct DataFrame from 2D array.
172
+
173
+ def dataframe_from_2d_array ( array : Any , * , schema : dict [ str , DType ]) -> DataFrame :
174
+ """ Construct DataFrame from 2D array.
154
175
155
176
See `column_from_1d_array` for related 1D function.
156
177
@@ -172,9 +193,9 @@ def dataframe_from_2d_array(array: Any, *, schema: Dict[str, DType]) -> DataFram
172
193
"""
173
194
...
174
195
175
- class null :
176
- """
177
- A `null` object to represent missing data.
196
+
197
+ class null : # noqa: N801
198
+ """ A `null` object to represent missing data.
178
199
179
200
``null`` is a scalar, and may be used when constructing a `Column` from a
180
201
Python sequence with `column_from_sequence`. It does not support ``is``,
@@ -198,11 +219,10 @@ class null:
198
219
used to check if an object *is* the ``null`` object.
199
220
200
221
"""
201
- ...
222
+
202
223
203
224
def is_null (value : object , / ) -> bool :
204
- """
205
- Check if an object is a `null` scalar.
225
+ """Check if an object is a `null` scalar.
206
226
207
227
Parameters
208
228
----------
@@ -217,9 +237,9 @@ def is_null(value: object, /) -> bool:
217
237
"""
218
238
...
219
239
240
+
220
241
def is_dtype (dtype : DType , kind : str | tuple [str , ...]) -> bool :
221
- """
222
- Returns a boolean indicating whether a provided dtype is of a specified data type “kind”.
242
+ """Indicate whether a provided dtype is of a specified data type "kind".
223
243
224
244
Parameters
225
245
----------
@@ -233,9 +253,11 @@ def is_dtype(dtype: DType, kind: str | tuple[str, ...]) -> bool:
233
253
234
254
- 'bool': boolean data type (Bool).
235
255
- 'signed integer': signed integer data types (Int8, Int16, Int32, Int64).
236
- - 'unsigned integer': unsigned integer data types (UInt8, UInt16, UInt32, UInt64).
256
+ - 'unsigned integer': unsigned integer data types
257
+ (UInt8, UInt16, UInt32, UInt64).
237
258
- 'floating': floating-point data types (Float32, Float64).
238
- - 'integral': integer data types. Shorthand for ('signed integer', 'unsigned integer').
259
+ - 'integral': integer data types. Shorthand for
260
+ ('signed integer', 'unsigned integer').
239
261
- 'numeric': numeric data types. Shorthand for ('integral', 'floating').
240
262
241
263
If kind is a tuple, the tuple specifies a union of dtypes and/or kinds,
@@ -249,11 +271,12 @@ def is_dtype(dtype: DType, kind: str | tuple[str, ...]) -> bool:
249
271
"""
250
272
...
251
273
274
+
252
275
def date (year : int , month : int , day : int ) -> Scalar :
253
- """
254
- Create date object which can be used for filtering.
276
+ """Create date object which can be used for filtering.
255
277
256
- The full 32-bit signed integer range of days since epoch should be supported (between -5877641-06-23 and 5881580-07-11 inclusive).
278
+ The full 32-bit signed integer range of days since epoch should be supported
279
+ (between -5877641-06-23 and 5881580-07-11 inclusive).
257
280
258
281
Examples
259
282
--------
@@ -265,4 +288,3 @@ def date(year: int, month: int, day: int) -> Scalar:
265
288
... )
266
289
>>> df.filter(mask)
267
290
"""
268
-
0 commit comments