Skip to content

Commit f821dbe

Browse files
Add some more dtypes: Date, Datetime, Duration, String (#197)
* add some more dtypes * add Date * remove notes on nbits * remove Date, note lack of guarantees * fixup * put Date back * fixup * postmerge fixup * add future annotations import --------- Co-authored-by: Ralf Gommers <[email protected]>
1 parent 0999051 commit f821dbe

File tree

4 files changed

+66
-4
lines changed

4 files changed

+66
-4
lines changed

spec/API_specification/dataframe_api/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
from __future__ import annotations
55

6-
from typing import Mapping, Sequence, Any, TYPE_CHECKING
6+
from typing import Mapping, Sequence, Any, Literal, TYPE_CHECKING
77

88
from .column_object import *
99
from .dataframe_object import DataFrame
@@ -35,6 +35,10 @@
3535
"Float64",
3636
"Float32",
3737
"Bool",
38+
"Date",
39+
"Datetime",
40+
"Duration",
41+
"String",
3842
"is_dtype",
3943
]
4044

spec/API_specification/dataframe_api/_types.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
UInt32,
3434
UInt16,
3535
UInt8,
36+
Date,
37+
Datetime,
38+
String,
3639
)
3740

3841
DType = Union[Bool, Float64, Float32, Int64, Int32, Int16, Int8, UInt64, UInt32, UInt16, UInt8]
@@ -57,14 +60,16 @@ def Column() -> ColumnType:
5760
...
5861

5962
@staticmethod
60-
def Int64() -> Int64:...
61-
@staticmethod
62-
def Int16() -> Int16:...
63+
def Int64() -> Int64:
64+
...
6365

6466
@staticmethod
6567
def Int32() -> Int32:
6668
...
6769

70+
@staticmethod
71+
def Int16() -> Int16:
72+
...
6873

6974
@staticmethod
7075
def Int8() -> Int8:
@@ -98,6 +103,18 @@ def Float32() -> Float32:
98103
def Bool() -> Bool:
99104
...
100105

106+
@staticmethod
107+
def Date() -> Date:
108+
...
109+
110+
@staticmethod
111+
def Datetime(time_unit: Literal['ms', 'us'], time_zone: str | None) -> Datetime:
112+
...
113+
114+
@staticmethod
115+
def String() -> String:
116+
...
117+
101118
@staticmethod
102119
def concat(dataframes: Sequence[DataFrameType]) -> DataFrameType:
103120
...

spec/API_specification/dataframe_api/dtypes.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
from __future__ import annotations
2+
3+
from typing import Literal
4+
5+
16
class Int64:
27
"""Integer type with 64 bits of precision."""
38

@@ -31,3 +36,35 @@ class Float32:
3136
class Bool:
3237
"""Boolean type with 8 bits of precision."""
3338

39+
class Date:
40+
"""
41+
Date type.
42+
43+
There is no guarantee about the range of dates available.
44+
"""
45+
46+
class Datetime:
47+
"""
48+
Datetime type.
49+
50+
Attributes
51+
----------
52+
time_unit : Literal['ms', 'us']
53+
Precision of the datetime type. There is no guarantee that the full
54+
range of dates available for the specified precision is supported.
55+
time_zone : str | None
56+
Time zone of the datetime type. Only IANA time zones are supported.
57+
`None` indicates time-zone-naive data.
58+
"""
59+
def __init__(self, *, time_unit: Literal['ms', 'us'], time_zone: str | None):
60+
...
61+
62+
time_unit: Literal['ms', 'us']
63+
time_zone: str | None # Only IANA time zones are supported
64+
65+
class Duration:
66+
"""Duration type."""
67+
time_unit: Literal['ms', 'us']
68+
69+
class String:
70+
"""String type."""

spec/API_specification/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ of objects and functions in the top-level namespace. The latter are:
2727
Float64
2828
Float32
2929
Bool
30+
Date
31+
Datetime
32+
Duration
33+
String
3034
is_dtype
3135
column_from_sequence
3236
column_from_1d_array

0 commit comments

Comments
 (0)