Skip to content

Commit 9d1e8cc

Browse files
authored
docs(examples): add type example (#10420)
1 parent dbde452 commit 9d1e8cc

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

ibis/expr/types/generic.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,30 @@ def name(self, name):
8888

8989
# TODO(kszucs): should rename to dtype
9090
def type(self) -> dt.DataType:
91-
"""Return the [DataType](./datatypes.qmd) of `self`."""
91+
"""Return the [DataType](./datatypes.qmd) of `self`.
92+
93+
Examples
94+
--------
95+
>>> from datetime import datetime
96+
>>> import ibis
97+
>>> ibis.options.interactive = True
98+
>>> t = ibis.memtable(
99+
... {
100+
... "int_col": [1],
101+
... "timestamp_col": [
102+
... datetime(2024, 11, 2, 10, 5, 2),
103+
... ],
104+
... "string_col": ["a"],
105+
... }
106+
... )
107+
108+
>>> t.int_col.type()
109+
Int64(nullable=True)
110+
>>> t.timestamp_col.type()
111+
Timestamp(timezone=None, scale=None, nullable=True)
112+
>>> t.string_col.type()
113+
String(nullable=True)
114+
"""
92115
return self.op().dtype
93116

94117
def hash(self) -> ir.IntegerValue:

0 commit comments

Comments
 (0)