Back

Explore Courses Blog Tutorials Interview Questions
0 votes
5 views
in Data Science by (120 points)

this is my code

import numpy as np

c=np.array([[1,2,3],[4,5,6]])

print(c)

op:[[1 2 3]

 [4 5 6]]
c=np.append[[7,8,9]])
getting below error
TypeError                                 Traceback (most recent call last)
<ipython-input-7-41f643cab810> in <module>
----> 1 c=np.append([7,8,9])

<__array_function__ internals> in append(*args, **kwargs)

TypeError: _append_dispatcher() missing 1 required positional argument: 'values'

1 Answer

0 votes
by (140 points)

You have only given 1 parameter (which is the array you want to add) but not given the 2nd parameter (which is what array to add to?). This should work for you:

import numpy as np

a = np.array([1,2,3],  [4,5,6])

b = np.array([7,8,9])

c = np.append(a, b)

print(c)

Browse Categories

...