insert(arr, obj, values, axis=None)
Note that for higher dimensional inserts :None:None:`obj=0`
behaves very different from :None:None:`obj=[0]`
just like :None:None:`arr[:,0,:] = values`
is different from :None:None:`arr[:,[0],:] = values`
.
Input array.
Object that defines the index or indices before which :None:None:`values`
is inserted.
Support for multiple insertions when :None:None:`obj`
is a single scalar or a sequence with one element (similar to calling insert multiple times).
Values to insert into :None:None:`arr`
. If the type of :None:None:`values`
is different from that of :None:None:`arr`
, :None:None:`values`
is converted to the type of :None:None:`arr`
. :None:None:`values`
should be shaped so that arr[...,obj,...] = values
is legal.
Axis along which to insert :None:None:`values`
. If :None:None:`axis`
is None then :None:None:`arr`
is flattened first.
A copy of :None:None:`arr`
with :None:None:`values`
inserted. Note that insert
does not occur in-place: a new array is returned. If :None:None:`axis`
is None, :None:None:`out`
is a flattened array.
Insert values along the given axis before the given indices.
append
Append elements at the end of an array.
concatenate
Join a sequence of arrays along an existing axis.
delete
Delete elements from an array.
>>> a = np.array([[1, 1], [2, 2], [3, 3]])
... a array([[1, 1], [2, 2], [3, 3]])
>>> np.insert(a, 1, 5) array([1, 5, 1, ..., 2, 3, 3])
>>> np.insert(a, 1, 5, axis=1) array([[1, 5, 1], [2, 5, 2], [3, 5, 3]])
Difference between sequence and scalars:
>>> np.insert(a, [1], [[1],[2],[3]], axis=1) array([[1, 1, 1], [2, 2, 2], [3, 3, 3]])
>>> np.array_equal(np.insert(a, 1, [1, 2, 3], axis=1),
... np.insert(a, [1], [[1],[2],[3]], axis=1)) True
>>> b = a.flatten()
... b array([1, 1, 2, 2, 3, 3])
>>> np.insert(b, [2, 2], [5, 6]) array([1, 1, 5, ..., 2, 3, 3])
>>> np.insert(b, slice(2, 4), [5, 6]) array([1, 1, 5, ..., 2, 3, 3])
>>> np.insert(b, [2, 2], [7.13, False]) # type casting array([1, 1, 7, ..., 2, 3, 3])
>>> x = np.arange(8).reshape(2, 4)See :
... idx = (1, 3)
... np.insert(x, idx, 999, axis=1) array([[ 0, 999, 1, 2, 999, 3], [ 4, 999, 5, 6, 999, 7]])
The following pages refer to to this document either explicitly or contain code examples using this.
scipy.linalg._decomp_update.qr_insert
dask.array.routines.insert
numpy.append
numpy.delete
numpy.insert
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them