-
Notifications
You must be signed in to change notification settings - Fork 131
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
enh: Adds support for Polars Time datatype #2113
base: main
Are you sure you want to change the base?
Changes from 9 commits
a6f763e
58f91c0
aa2e7ba
f256b9a
b284e02
c992c52
88580bb
ffd6925
cac56a8
c8b3aed
5b73e5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ | |
- Object | ||
- Unknown | ||
- UnsignedIntegerType | ||
- Time | ||
show_root_heading: false | ||
show_source: false | ||
show_bases: false |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -412,6 +412,8 @@ def non_object_native_to_narwhals_dtype(dtype: str, version: Version) -> DType: | |
return dtypes.Date() | ||
if dtype.startswith("decimal") and dtype.endswith("[pyarrow]"): | ||
return dtypes.Decimal() | ||
if dtype.startswith("time") and dtype.endswith("[pyarrow]"): | ||
return dtypes.Time() | ||
return dtypes.Unknown() # pragma: no cover | ||
|
||
|
||
|
@@ -610,7 +612,9 @@ def narwhals_to_native_dtype( # noqa: PLR0915 | |
if isinstance_or_issubclass(dtype, dtypes.Enum): | ||
msg = "Converting to Enum is not (yet) supported" | ||
raise NotImplementedError(msg) | ||
if isinstance_or_issubclass(dtype, (dtypes.Struct, dtypes.Array, dtypes.List)): | ||
if isinstance_or_issubclass( | ||
dtype, (dtypes.Struct, dtypes.Array, dtypes.List, dtypes.Time) | ||
): | ||
if implementation is Implementation.PANDAS and backend_version >= (2, 2): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated, but... should we check modin backed by pyarrow? |
||
try: | ||
import pandas as pd | ||
|
FBruzzesi marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,9 +142,10 @@ def narwhals_to_native_dtype( | |
dtypes.UInt8, | ||
dtypes.Enum, | ||
dtypes.Categorical, | ||
dtypes.Time, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't find a datatype in pyspark for this, so it will just end up in the unsupported list |
||
), | ||
): # pragma: no cover | ||
msg = "Unsigned integer, Enum and Categorical types are not supported by spark-like backend" | ||
msg = "Unsigned integer, Enum, Categorical and Time types are not supported by spark-like backend" | ||
raise UnsupportedDTypeError(msg) | ||
|
||
msg = f"Unknown dtype: {dtype}" # pragma: no cover | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pattern is
time<32|64>[<unit>][pyarrow]
Example: