Append values to the end of an array. Parameters ---------- arr : array_like Values are appended to a copy of this array. values : array_like These values are appended to a copy of `arr`. It must be of the correct shape (the same shape as `arr`, excludi
(arr, values, axis=None)
| 5562 | |
| 5563 | @array_function_dispatch(_append_dispatcher) |
| 5564 | def append(arr, values, axis=None): |
| 5565 | """ |
| 5566 | Append values to the end of an array. |
| 5567 | |
| 5568 | Parameters |
| 5569 | ---------- |
| 5570 | arr : array_like |
| 5571 | Values are appended to a copy of this array. |
| 5572 | values : array_like |
| 5573 | These values are appended to a copy of `arr`. It must be of the |
| 5574 | correct shape (the same shape as `arr`, excluding `axis`). If |
| 5575 | `axis` is not specified, `values` can be any shape and will be |
| 5576 | flattened before use. |
| 5577 | axis : int, optional |
| 5578 | The axis along which `values` are appended. If `axis` is not |
| 5579 | given, both `arr` and `values` are flattened before use. |
| 5580 | |
| 5581 | Returns |
| 5582 | ------- |
| 5583 | append : ndarray |
| 5584 | A copy of `arr` with `values` appended to `axis`. Note that |
| 5585 | `append` does not occur in-place: a new array is allocated and |
| 5586 | filled. If `axis` is None, `out` is a flattened array. |
| 5587 | |
| 5588 | See Also |
| 5589 | -------- |
| 5590 | insert : Insert elements into an array. |
| 5591 | delete : Delete elements from an array. |
| 5592 | |
| 5593 | Examples |
| 5594 | -------- |
| 5595 | >>> np.append([1, 2, 3], [[4, 5, 6], [7, 8, 9]]) |
| 5596 | array([1, 2, 3, ..., 7, 8, 9]) |
| 5597 | |
| 5598 | When `axis` is specified, `values` must have the correct shape. |
| 5599 | |
| 5600 | >>> np.append([[1, 2, 3], [4, 5, 6]], [[7, 8, 9]], axis=0) |
| 5601 | array([[1, 2, 3], |
| 5602 | [4, 5, 6], |
| 5603 | [7, 8, 9]]) |
| 5604 | >>> np.append([[1, 2, 3], [4, 5, 6]], [7, 8, 9], axis=0) |
| 5605 | Traceback (most recent call last): |
| 5606 | ... |
| 5607 | ValueError: all the input arrays must have same number of dimensions, but |
| 5608 | the array at index 0 has 2 dimension(s) and the array at index 1 has 1 |
| 5609 | dimension(s) |
| 5610 | |
| 5611 | """ |
| 5612 | arr = asanyarray(arr) |
| 5613 | if axis is None: |
| 5614 | if arr.ndim != 1: |
| 5615 | arr = arr.ravel() |
| 5616 | values = ravel(values) |
| 5617 | axis = arr.ndim-1 |
| 5618 | return concatenate((arr, values), axis=axis) |
| 5619 | |
| 5620 | |
| 5621 | def _digitize_dispatcher(x, bins, right=None): |
nothing calls this directly
no test coverage detected