Skip to content

Commit 8a6ef43

Browse files
authored
Merge pull request numpy#26303 from tuhinsharma121/np-append-documentation-enhancement
DOC: add explanation of dtype to parameter values for np.append
2 parents 552fdd4 + 853c42b commit 8a6ef43

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

numpy/lib/_function_base_impl.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5743,13 +5743,24 @@ def append(arr, values, axis=None):
57435743
array([[1, 2, 3],
57445744
[4, 5, 6],
57455745
[7, 8, 9]])
5746+
57465747
>>> np.append([[1, 2, 3], [4, 5, 6]], [7, 8, 9], axis=0)
57475748
Traceback (most recent call last):
57485749
...
57495750
ValueError: all the input arrays must have same number of dimensions, but
57505751
the array at index 0 has 2 dimension(s) and the array at index 1 has 1
57515752
dimension(s)
57525753
5754+
>>> a = np.array([1, 2], dtype=int)
5755+
>>> c = np.append(a, [])
5756+
>>> c
5757+
array([1., 2.])
5758+
>>> c.dtype
5759+
float64
5760+
5761+
Default dtype for empty ndarrays is `float64` thus making the output of dtype
5762+
`float64` when appended with dtype `int64`
5763+
57535764
"""
57545765
arr = asanyarray(arr)
57555766
if axis is None:

0 commit comments

Comments
 (0)