Skip to content

Commit 7a8b86b

Browse files
add extend array to writing tutorial
1 parent 8a8ffb6 commit 7a8b86b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/source/tutorials/writing.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ Write array and tabular data.
6060
>>> client.write_array(numpy.array([4, 5, 6]), metadata={"color": "blue", "barcode": 11})
6161
<ArrayClient shape=(3,) chunks=((3,),) dtype=int64>
6262

63+
# Create an array and grow it by one
64+
>>> new_array = client.write_array([1, 2, 3])
65+
>>> new_array
66+
<ArrayClient shape=(3,) chunks=((3,),) dtype=int64>
67+
68+
# Extend the array. This array has only one dimension, here we extend by one
69+
# along that dimension.
70+
>>> new_array.patch([4], offset=(3,), extend=True)
71+
>>> new_array
72+
<ArrayClient shape=(4,) chunks=((3, 1),) dtype=int64>
73+
>>> new_array.read()
74+
array([1, 2, 3, 4])
75+
>>>
76+
6377
# Write a table (DataFrame).
6478
>>> import pandas
6579
>>> client.write_dataframe(pandas.DataFrame({"x": [1, 2, 3], "y": [4, 5, 6]}), metadata={"color": "green", "barcode": 12})

0 commit comments

Comments
 (0)