0

I am using a function X , that takes np.ndarray, shape=(num_pairs, 2), dtype=int values . I have just a list l=[a,b] and I want to give this list to the above function X as input.

I get the error as * l must be ndim 2. You supplied 1 *

Is there any way around to submit this list to the function ?

Hai Vu
  • 37,849
  • 11
  • 66
  • 93

1 Answers1

-1

See this answer.

>>> import numpy as np
>>> l = np.array([1,2])
>>> l
array([1, 2])
>>> l.shape
(2,)
>>> l.ndim
1
>>> l[None, :].shape
(1, 2)
>>> l[None, :].ndim
2
Community
  • 1
  • 1
wildwilhelm
  • 4,809
  • 1
  • 19
  • 24
  • If all you have is a reference to another answer, please vote to close the question as a duplicate of that one. – TigerhawkT3 Oct 27 '16 at 14:26