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
31 changes: 30 additions & 1 deletion 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 All @@ -30,6 +30,10 @@
"Float64",
"Float32",
"Bool",
"Date",
"Datetime",
"Duration",
"String",
]


Expand Down Expand Up @@ -177,3 +181,28 @@ class Float32:

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

class Date:
"""Date 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.
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."""
4 changes: 4 additions & 0 deletions spec/API_specification/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down