Skip to content

Commit

Permalink
Add doctest example
Browse files Browse the repository at this point in the history
Co-authored-by: Spencer Nelson <[email protected]>
  • Loading branch information
moeyensj and spenczar committed Sep 29, 2023
1 parent f79730e commit fc18103
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion quivr/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,9 +668,23 @@ def column(self, column_name: str) -> pa.ChunkedArray:
"""
Returns the column with the given name as a raw pyarrow ChunkedArray.
Column can be a nested column, in which case, this function will recursively
search for the column through the nested subtables.
search for the column through the nested subtables using dot-delimited notation.
:param column_name: The name of the column to return.
Examples:
>>> import quivr as qv
>>> import pyarrow.compute as pc
>>> class MySubTable(qv.Table):
... x = qv.Int64Column()
... y = qv.Int64Column()
>>> class MyWrapperTable(qv.Table):
... child = MySubTable.as_column()
>>> c = MySubTable.from_kwargs(x=[1, 2, 3], y=[4, 5, 6])
>>> p = MyWrapperTable.from_kwargs(child=c)
>>> column_x = p.column("c.x")
>>> print(column_x.to_pylist())
[1, 2, 3]
"""
if "." in column_name:
column_name, subkey = column_name.split(".", 1)
Expand Down

0 comments on commit fc18103

Please sign in to comment.