Skip to content

Commit 26d97e5

Browse files
docs: add docstrings examples for Int128 and UInt128 (#2396)
* docstrings examples for Int128 and UInt128 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 340c77f commit 26d97e5

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

narwhals/dtypes.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,23 @@ class Decimal(NumericType):
112112

113113

114114
class Int128(SignedIntegerType):
115-
"""128-bit signed integer type."""
115+
"""128-bit signed integer type.
116+
117+
Examples:
118+
>>> import polars as pl
119+
>>> import pyarrow as pa
120+
>>> import narwhals as nw
121+
>>> import duckdb
122+
>>> s_native = pl.Series([2, 1, 3, 7])
123+
>>> s = nw.from_native(s_native, series_only=True)
124+
>>> df_native = pa.table({"a": [2, 1, 3, 7]})
125+
>>> rel = duckdb.sql(" SELECT CAST (a AS INT128) AS a FROM df_native ")
126+
127+
>>> s.cast(nw.Int128).dtype
128+
Int128
129+
>>> nw.from_native(rel).schema["a"]
130+
Int128
131+
"""
116132

117133

118134
class Int64(SignedIntegerType):
@@ -168,7 +184,17 @@ class Int8(SignedIntegerType):
168184

169185

170186
class UInt128(UnsignedIntegerType):
171-
"""128-bit unsigned integer type."""
187+
"""128-bit unsigned integer type.
188+
189+
Examples:
190+
>>> import pandas as pd
191+
>>> import narwhals as nw
192+
>>> import duckdb
193+
>>> df_native = pd.DataFrame({"a": [2, 1, 3, 7]})
194+
>>> rel = duckdb.sql(" SELECT CAST (a AS UINT128) AS a FROM df_native ")
195+
>>> nw.from_native(rel).schema["a"]
196+
UInt128
197+
"""
172198

173199

174200
class UInt64(UnsignedIntegerType):

0 commit comments

Comments
 (0)