May 2019
Beginner
528 pages
29h 51m
English
arrays from Existing DataThe NumPy documentation recommends importing the numpy module as np so that you can access its members with "np.":
In [1]: import numpy as np
The numpy module provides various functions for creating arrays. Here we use the array function, which receives as an argument an array or other collection of elements and returns a new array containing the argument’s elements. Let’s pass a list:
In [2]: numbers = np.array([2, 3, 5, 7, 11])
The array function copies its argument’s contents into the array. Let’s look at the type of object that function array returns and display its contents:
In [3]: type(numbers)Out[3]: numpy.ndarrayIn [4]: numbersOut[4]: array([ 2, 3, 5, 7, 11])
Note that the type is numpy.ndarray ...
Read now
Unlock full access