From 07bb3d8ee7b8ab53b17b57d7474677a331396dda Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Wed, 12 Jul 2023 11:24:14 +0100 Subject: [PATCH 1/9] add some more dtypes --- .../dataframe_api/__init__.py | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/spec/API_specification/dataframe_api/__init__.py b/spec/API_specification/dataframe_api/__init__.py index ed664363..b2edd29c 100644 --- a/spec/API_specification/dataframe_api/__init__.py +++ b/spec/API_specification/dataframe_api/__init__.py @@ -3,7 +3,7 @@ """ from __future__ import annotations -from typing import Mapping, Sequence, Any +from typing import Mapping, Sequence, Any, Literal from .column_object import * from .dataframe_object import DataFrame @@ -177,3 +177,25 @@ class Float32: class Bool: """Boolean type with 8 bits of precision.""" + +class Datetime: + """ + Datetime type with 64 bits of precision. + + Attributes + ---------- + time_unit : Literal['ms', 'us', 'ns'] + Precision of the datetime type. + time_zone : str | None + Time zone of the datetime type. Only IANA time zones are supported. + `None` indicates time-zone-naive data. + """ + time_unit: Literal['ms', 'us', 'ns'] + time_zone: str | None # Only IANA time zones are supported + +class Duration: + """Duration type with 64 bits of precision.""" + time_unit: Literal['ms', 'us', 'ns'] + +class String: + """String type.""" From 1d7682c87f94c8de931adfcf9f5fe4188d6fdd8f Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Wed, 12 Jul 2023 11:43:29 +0100 Subject: [PATCH 2/9] add Date --- spec/API_specification/dataframe_api/__init__.py | 9 ++++++++- spec/API_specification/index.rst | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/spec/API_specification/dataframe_api/__init__.py b/spec/API_specification/dataframe_api/__init__.py index b2edd29c..a9aab6f5 100644 --- a/spec/API_specification/dataframe_api/__init__.py +++ b/spec/API_specification/dataframe_api/__init__.py @@ -30,6 +30,10 @@ "Float64", "Float32", "Bool", + "Date", + "Datetime", + "Duration", + "String", ] @@ -178,9 +182,12 @@ class Float32: class Bool: """Boolean type with 8 bits of precision.""" +class Date: + """Date type.""" + class Datetime: """ - Datetime type with 64 bits of precision. + Datetime type. Attributes ---------- diff --git a/spec/API_specification/index.rst b/spec/API_specification/index.rst index b90d3320..1c4e2704 100644 --- a/spec/API_specification/index.rst +++ b/spec/API_specification/index.rst @@ -27,6 +27,10 @@ of objects and functions in the top-level namespace. The latter are: Float64 Float32 Bool + Date + Datetime + Duration + String The ``DataFrame``, ``Column`` and ``GroupBy`` objects have the following methods and attributes: From 82bc5cbd682d11df9f995c5cf375a8283bbadb27 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Thu, 13 Jul 2023 08:33:19 +0100 Subject: [PATCH 3/9] remove notes on nbits --- spec/API_specification/dataframe_api/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/API_specification/dataframe_api/__init__.py b/spec/API_specification/dataframe_api/__init__.py index a9aab6f5..696ba910 100644 --- a/spec/API_specification/dataframe_api/__init__.py +++ b/spec/API_specification/dataframe_api/__init__.py @@ -180,7 +180,7 @@ class Float32: """Floating point type with 32 bits of precision.""" class Bool: - """Boolean type with 8 bits of precision.""" + """Boolean type.""" class Date: """Date type.""" @@ -201,7 +201,7 @@ class Datetime: time_zone: str | None # Only IANA time zones are supported class Duration: - """Duration type with 64 bits of precision.""" + """Duration type.""" time_unit: Literal['ms', 'us', 'ns'] class String: From f5c4e55e57710734ddf1a34e421bcd8023f0e8b8 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Wed, 26 Jul 2023 10:57:09 +0100 Subject: [PATCH 4/9] remove Date, note lack of guarantees --- spec/API_specification/dataframe_api/__init__.py | 7 ++----- spec/API_specification/index.rst | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/spec/API_specification/dataframe_api/__init__.py b/spec/API_specification/dataframe_api/__init__.py index 696ba910..b71c2dbd 100644 --- a/spec/API_specification/dataframe_api/__init__.py +++ b/spec/API_specification/dataframe_api/__init__.py @@ -30,7 +30,6 @@ "Float64", "Float32", "Bool", - "Date", "Datetime", "Duration", "String", @@ -182,9 +181,6 @@ class Float32: class Bool: """Boolean type.""" -class Date: - """Date type.""" - class Datetime: """ Datetime type. @@ -192,7 +188,8 @@ class Datetime: Attributes ---------- time_unit : Literal['ms', 'us', 'ns'] - Precision of the datetime type. + Precision of the datetime type. There is no guarantee that the full + range of dates available for the specified precision is supported. time_zone : str | None Time zone of the datetime type. Only IANA time zones are supported. `None` indicates time-zone-naive data. diff --git a/spec/API_specification/index.rst b/spec/API_specification/index.rst index 1c4e2704..3ed7fcd8 100644 --- a/spec/API_specification/index.rst +++ b/spec/API_specification/index.rst @@ -27,7 +27,6 @@ of objects and functions in the top-level namespace. The latter are: Float64 Float32 Bool - Date Datetime Duration String From a90e3fe4d1d82739a285189686a5f732bf1f2e0e Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Wed, 27 Sep 2023 12:08:22 +0100 Subject: [PATCH 5/9] fixup --- spec/API_specification/index.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/spec/API_specification/index.rst b/spec/API_specification/index.rst index 0ca36a62..0b198274 100644 --- a/spec/API_specification/index.rst +++ b/spec/API_specification/index.rst @@ -27,13 +27,10 @@ of objects and functions in the top-level namespace. The latter are: Float64 Float32 Bool -<<<<<<< HEAD Datetime Duration String -======= is_dtype ->>>>>>> upstream/main column_from_sequence column_from_1d_array dataframe_from_dict From ea56e11706f932717e4d96c8fabb3b17c7d88f5e Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Wed, 27 Sep 2023 12:13:42 +0100 Subject: [PATCH 6/9] put Date back --- spec/API_specification/dataframe_api/__init__.py | 7 +++++++ spec/API_specification/index.rst | 1 + 2 files changed, 8 insertions(+) diff --git a/spec/API_specification/dataframe_api/__init__.py b/spec/API_specification/dataframe_api/__init__.py index 27855d89..de75b2d6 100644 --- a/spec/API_specification/dataframe_api/__init__.py +++ b/spec/API_specification/dataframe_api/__init__.py @@ -269,6 +269,13 @@ class Float32: class Bool: """Boolean type.""" +class Datetime: + """ + Date type. + + There is no guarantee about the range of dates available. + """ + class Datetime: """ Datetime type. diff --git a/spec/API_specification/index.rst b/spec/API_specification/index.rst index 0b198274..04c290b1 100644 --- a/spec/API_specification/index.rst +++ b/spec/API_specification/index.rst @@ -27,6 +27,7 @@ of objects and functions in the top-level namespace. The latter are: Float64 Float32 Bool + Date Datetime Duration String From a96d9c486e29bceb2b228c60bdbae122ca9b6d52 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Wed, 27 Sep 2023 12:33:33 +0100 Subject: [PATCH 7/9] fixup --- spec/API_specification/dataframe_api/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/API_specification/dataframe_api/__init__.py b/spec/API_specification/dataframe_api/__init__.py index de75b2d6..553feb67 100644 --- a/spec/API_specification/dataframe_api/__init__.py +++ b/spec/API_specification/dataframe_api/__init__.py @@ -32,6 +32,10 @@ "Float64", "Float32", "Bool", + "Date", + "Datetime", + "Duration", + "String", "is_dtype", ] @@ -269,7 +273,7 @@ class Float32: class Bool: """Boolean type.""" -class Datetime: +class Date: """ Date type. From a28f2101390f01a1dfa4ec4d54e8cd7558ee5d98 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Thu, 28 Sep 2023 17:53:03 +0100 Subject: [PATCH 8/9] postmerge fixup --- .../dataframe_api/__init__.py | 78 +------------------ .../API_specification/dataframe_api/_types.py | 9 ++- 2 files changed, 7 insertions(+), 80 deletions(-) diff --git a/spec/API_specification/dataframe_api/__init__.py b/spec/API_specification/dataframe_api/__init__.py index bc58df4e..4829eb48 100644 --- a/spec/API_specification/dataframe_api/__init__.py +++ b/spec/API_specification/dataframe_api/__init__.py @@ -3,11 +3,7 @@ """ from __future__ import annotations -<<<<<<< HEAD -from typing import Mapping, Sequence, Any, Literal -======= -from typing import Mapping, Sequence, Any, TYPE_CHECKING ->>>>>>> upstream/main +from typing import Mapping, Sequence, Any, Literal, TYPE_CHECKING from .column_object import * from .dataframe_object import DataFrame @@ -215,79 +211,7 @@ def is_null(value: object, /) -> bool: """ -<<<<<<< HEAD -########## -# Dtypes # -########## - -class Int64: - """Integer type with 64 bits of precision.""" - -class Int32: - """Integer type with 32 bits of precision.""" - -class Int16: - """Integer type with 16 bits of precision.""" - -class Int8: - """Integer type with 8 bits of precision.""" - -class UInt64: - """Unsigned integer type with 64 bits of precision.""" - -class UInt32: - """Unsigned integer type with 32 bits of precision.""" - -class UInt16: - """Unsigned integer type with 16 bits of precision.""" - -class UInt8: - """Unsigned integer type with 8 bits of precision.""" - -class Float64: - """Floating point type with 64 bits of precision.""" - -class Float32: - """Floating point type with 32 bits of precision.""" - -class Bool: - """Boolean type.""" - -class Date: - """ - Date type. - - There is no guarantee about the range of dates available. - """ - -class Datetime: - """ - Datetime type. - - Attributes - ---------- - time_unit : Literal['ms', 'us'] - Precision of the datetime type. There is no guarantee that the full - range of dates available for the specified precision is supported. - time_zone : str | None - Time zone of the datetime type. Only IANA time zones are supported. - `None` indicates time-zone-naive data. - """ - time_unit: Literal['ms', 'us'] - time_zone: str | None # Only IANA time zones are supported - -class Duration: - """Duration type.""" - time_unit: Literal['ms', 'us'] - -class String: - """String type.""" - - -def is_dtype(dtype: Any, kind: str | tuple[str, ...]) -> bool: -======= def is_dtype(dtype: DType, kind: str | tuple[str, ...]) -> bool: ->>>>>>> upstream/main """ Returns a boolean indicating whether a provided dtype is of a specified data type “kind”. diff --git a/spec/API_specification/dataframe_api/_types.py b/spec/API_specification/dataframe_api/_types.py index e06323c1..90b894cf 100644 --- a/spec/API_specification/dataframe_api/_types.py +++ b/spec/API_specification/dataframe_api/_types.py @@ -33,6 +33,9 @@ UInt32, UInt16, UInt8, + Date, + Datetime, + String, ) DType = Union[Bool, Float64, Float32, Int64, Int32, Int16, Int8, UInt64, UInt32, UInt16, UInt8] @@ -101,15 +104,15 @@ def Bool() -> Bool: ... @staticmethod - def Date() -> Bool: + def Date() -> Date: ... @staticmethod - def Datetime(time_unit: Literal['ms', 'us'], time_zone: str | None) -> Bool: + def Datetime(time_unit: Literal['ms', 'us'], time_zone: str | None) -> Datetime: ... @staticmethod - def String() -> Bool: + def String() -> String: ... @staticmethod From e4f3e7f598572317d9e62579875e71eb7b877d78 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Sat, 30 Sep 2023 09:19:39 +0100 Subject: [PATCH 9/9] add future annotations import --- spec/API_specification/dataframe_api/dtypes.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/API_specification/dataframe_api/dtypes.py b/spec/API_specification/dataframe_api/dtypes.py index f51a3ed4..5af4072e 100644 --- a/spec/API_specification/dataframe_api/dtypes.py +++ b/spec/API_specification/dataframe_api/dtypes.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import Literal @@ -65,4 +67,4 @@ class Duration: time_unit: Literal['ms', 'us'] class String: - """String type.""" \ No newline at end of file + """String type."""