9951 explained code solutions for 126 technologies


python-numpyHow to append row to Numpy array


import numpy as np
arr = np.array([[1, 2]])
arr = np.append(arr, [[3, 4]], axis=0)ctrl + c
import numpy as np

load Numpy module for Python

np.array

declare Numpy array

[[1, 2]]

sample 2-dimensional array

np.append

append values to specified array

arr

array to append new values to

[[3, 4]]

new values array to append to arr (should have the same dimension count)

axis=0

axis to add new values along