Answers for "how to create an array in numpy"

2

numpy array from list

>>> a = [1, 2]
>>> np.asarray(a)
array([1, 2])
Posted by: Guest on September-21-2020
0

array creation method in numpy

>>> np.arange(10)
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> np.arange(2, 10, dtype=float)
array([ 2., 3., 4., 5., 6., 7., 8., 9.])
>>> np.arange(2, 3, 0.1)
array([ 2. , 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9])
Posted by: Guest on May-31-2021

Code answers related to "how to create an array in numpy"

Browse Popular Code Answers by Language