Data are often naturally arranged in vectors or matrices, i.e. in multi-dimensional arrays. While this may appear as obvious for scientific applications, it is often the case in other areas as well. For example, two-dimensional colour images can be represented in terms of three-dimensional arrays.
Multi-dimensional arrays are provided by the NumPy library. NumPy arrays usually lead to a significant speed-up as compared to standard Python code. They also allow to write more succinct and readable code. Therefore, anybody using Python to handle numerical datasets will need a good working knowledge of NumPy arrays.
In this tutorial, we will learn the basic concepts of NumPy's array data type, the ndarray
. In particular, we will see how ndarray
s can be indexed and how shape
and strides
are used to efficiently work with ndarray
s. Furthermore, we will take a look at how ndarray
s can be manipulated with NumPy and we will explore how typical tasks can be
addressed either with NumPy or other packages from the Python scientific stack like SciPy.
A basic working knowledge of Python is expected. Particularly useful will be familiarity with the slicing syntax of Python lists.
An important aim of the tutorial is to gain practical experience with NumPy. You are therefore strongly encouraged to bring your laptop, ideally with a recent version of Python, NumPy, SciPy, and matplotlib already installed. For ease of installation we recommend the freely available Anaconda distribution. Choose the Python3 version for your operating system and follow the instruction on the Anaconda downloads page. An existing Python2 installation will do fine as well.
Material for the tutorial will be made available at github.com/gertingold/euroscipy16-numpy-tutorial.