Skip to content

Commit

Permalink
add extend array to writing tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanmcreynolds committed Nov 8, 2024
1 parent 8a8ffb6 commit 7a8b86b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/source/tutorials/writing.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ Write array and tabular data.
>>> client.write_array(numpy.array([4, 5, 6]), metadata={"color": "blue", "barcode": 11})
<ArrayClient shape=(3,) chunks=((3,),) dtype=int64>

# Create an array and grow it by one
>>> new_array = client.write_array([1, 2, 3])
>>> new_array
<ArrayClient shape=(3,) chunks=((3,),) dtype=int64>

# Extend the array. This array has only one dimension, here we extend by one
# along that dimension.
>>> new_array.patch([4], offset=(3,), extend=True)
>>> new_array
<ArrayClient shape=(4,) chunks=((3, 1),) dtype=int64>
>>> new_array.read()
array([1, 2, 3, 4])
>>>

# Write a table (DataFrame).
>>> import pandas
>>> client.write_dataframe(pandas.DataFrame({"x": [1, 2, 3], "y": [4, 5, 6]}), metadata={"color": "green", "barcode": 12})
Expand Down

0 comments on commit 7a8b86b

Please sign in to comment.