Skip to content

Commit

Permalink
docs(examples): add type example
Browse files Browse the repository at this point in the history
  • Loading branch information
IndexSeek committed Nov 2, 2024
1 parent 8dbbc8b commit 6edc66f
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion ibis/expr/types/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,30 @@ def name(self, name):

# TODO(kszucs): should rename to dtype
def type(self) -> dt.DataType:
"""Return the [DataType](./datatypes.qmd) of `self`."""
"""Return the [DataType](./datatypes.qmd) of `self`.
Examples
--------
>>> from datetime import datetime
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable(
... {
... "int_col": [1],
... "timestamp_col": [
... datetime(2024, 11, 2, 10, 5, 2),
... ],
... "string_col": ["a"],
... }
... )
>>> t.int_col.type()
Int64(nullable=True)
>>> t.timestamp_col.type()
Timestamp(timezone=None, scale=None, nullable=True)
>>> t.string_col.type()
String(nullable=True)
"""
return self.op().dtype

def hash(self) -> ir.IntegerValue:
Expand Down

0 comments on commit 6edc66f

Please sign in to comment.