Skip to content

Add some more dtypes: Date, Datetime, Duration, String #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Sep 30, 2023
30 changes: 28 additions & 2 deletions spec/API_specification/dataframe_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -32,6 +32,9 @@
"Float64",
"Float32",
"Bool",
"Datetime",
"Duration",
"String",
]


Expand Down Expand Up @@ -238,4 +241,27 @@ class Float32:
"""Floating point type with 32 bits of precision."""

class Bool:
"""Boolean type with 8 bits of precision."""
"""Boolean type."""

class Datetime:
"""
Datetime type.

Attributes
----------
time_unit : Literal['ms', 'us', 'ns']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having gone through some work in this area recently, nanosecond support isn't common in relational databases where for example DuckDB and Postgres do datetimes as number of microseconds (DuckDB Postgres). Going from microseconds upwards to milliseconds and seconds is generally more easily handled and straightforward, but going down to nanoseconds is not.

Maybe we should consider punting on nanoseconds for the time being?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

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', 'ns']
time_zone: str | None # Only IANA time zones are supported

class Duration:
"""Duration type."""
time_unit: Literal['ms', 'us', 'ns']

class String:
"""String type."""
3 changes: 3 additions & 0 deletions spec/API_specification/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ of objects and functions in the top-level namespace. The latter are:
Float64
Float32
Bool
Datetime
Duration
String
column_from_sequence
column_from_1d_array
dataframe_from_dict
Expand Down