NumPy arrays
Vectors and matrices are not available in core Python. In order to use them, you will have to import the NumPy library. Just as how you used dot notation to access methods of an object,
you can use the dot notation to access functions from a library. Recall that you can import a library using an alias. For example, to import package
as pk
, you can use:
import package as pk
Within the numpy library, you can use the loadtxt()
function to import files.
For example, you can load a file named data.csv
using numpy with numpy.loadtxt('data.csv')
. The loadtxt()
function has a delimiter
parameter which lets you specify that your data is separated by commas.
Cet exercice fait partie du cours
Python for R Users
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Import the numpy library using the alias: np
____ ____ ____ ____