A Brief Introduction to NumPy¶
Where we have been¶
In the Python classes to date (ADD LINKS) we discussed some important programming basics and learnt some important fundamentals of the Python language. This is rarely enough to do scientific research on its own.
NumPy¶
In this module, we introduce the NumPy
module, which is perhaps the fundamental package for scientific computing in Python. Numpy provides the core tool of scientific computing, N-dimensional arrays, as well as tools to work with these arrays.
NumPy’s N-dimensional array and functionality gives us, the user, efficient storage and operations on arrays - even when they grow large in size.
We import the NumPy library as follows:
import numpy as np
where we have followed the ‘standard convention’ of importing numpy under the alias ‘np
.’
We can check the version of NumPy which we have installed on our machine as follows:
np.__version__
'1.21.2'
We recommend having a version of NumPy that is version 1.10 or later; but for what we are covering this should not matter too much. If you want to update your NumPy to the latest version you can use the following command in a terminal
$ pip install numpy --upgrade
to update using the pip
package manager, or using Anaconda’s own package manager, conda by entering the command in a terminal
$ conda update numpy
Where to Next?¶
The following notebooks provide a relatively condensed introduction to the NumPy library. That said, we hope to have provided enough information for you to feel comfortable doing array computing using the library.
Once we are comfortable with the NumPy library, we will continue our journey into scientific computing with Python, looking further into:
Pandas
- easy-to-use data structures and data analysis toolsMatplotlib
- plotting library which produces publication quality figuresStatsmodels
andlinearmodels
- the estimation of statistical models, and statistical data explorationSciPy
- user-friendly and efficient numerical routines
all of these libraries rely heavily on functionality from the the N-dimensional array object that NumPy provides.