Skip to content

Commit

Permalink
feat(api): add ibis.dtype top-level API
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrist committed Aug 2, 2023
1 parent 39b7a24 commit 867e5f1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/reference/expressions/top_level.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ These methods and objects are available directly in the `ibis` module.
::: ibis.deferred
::: ibis.desc
::: ibis.difference
::: ibis.dtype
::: ibis.get_backend
::: ibis.expr.types.Value.greatest
::: ibis.ifelse
Expand Down
2 changes: 2 additions & 0 deletions ibis/expr/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
'decompile',
'deferred',
'difference',
'dtype',
'e',
'Expr',
'geo_area',
Expand Down Expand Up @@ -163,6 +164,7 @@
)


dtype = dt.dtype
infer_dtype = dt.infer
infer_schema = sch.infer

Expand Down
13 changes: 13 additions & 0 deletions ibis/expr/datatypes/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ def dtype(value: Any, nullable: bool = True) -> DataType:
Int32(nullable=True)
>>> ibis.dtype("array<float>")
Array(value_type=Float64(nullable=True), nullable=True)
DataType objects may also be created from Python types:
>>> ibis.dtype(int)
Int64(nullable=True)
>>> ibis.dtype(list[float])
Array(value_type=Float64(nullable=True), nullable=True)
Or other type systems, like numpy/pandas/pyarrow types:
>>> import pyarrow as pa
>>> ibis.dtype(pa.int32())
Int32(nullable=True)
"""
if isinstance(value, DataType):
return value
Expand Down

0 comments on commit 867e5f1

Please sign in to comment.