
Explore NumPy, the numerical Python library underpinning quantitative data and data science modules, and understand the main data type ndarray and why a new data type is needed beyond lists.
Explore the standard module's array type, converting lists to typed arrays and examining type codes, memory efficiency, and data-type constraints compared to lists as we prepare to learn numpy.
You can use tools in your IDE, or go to the Terminal and type:
python -m pip install numpy
If you're using a virtual environment, make sure you've activated the virtual environment before installing.
Explore how the numpy ndarray extends lists with multi-dimensional data, and inspect shape and dimensions. Learn to convert data types with astype and perform axis-based max operations.
The lecture compares a classic loop, a list comprehension, and numpy for multiplying data by ten, timing each with timeit, and highlights numpy's speed through vectorization.
Explore the numpy documentation to master function signatures, default values, and vectorization, and learn how to use numpy.max and ndarray.max with practical examples.
Explore how numpy arrays extend lists to two dimensions, using indexing and slices to access rows, columns, and subarrays, and compare dimensionality and shapes.
Explore NumPy broadcasting by aligning shapes, using 1D and 2D corrections on a 5x3 data array, and applying transpose to broadcast across rows.
Explore how to generate random integers with numpy's generator, customize with low, high, size, and dtype, and create zero and one-filled arrays, preparing for 3D arrays and basic image creation.
Explore how to use numpy to create and manipulate 3d arrays (100 by 100 by 3) that represent images, including red, green, and blue channels, and visualize them with matplotlib.
Explore how numpy arrays enable vectorized, elementwise operations—multiplication, addition, and exponentiation—producing new arrays and boolean results from comparisons like greater than and equals.
Explore the basics of NumPy, focusing on broadcasting rules, vectorized operations, and handling arrays of numbers and strings with practical API insights.
Explore views and copies in numpy, comparing numpy arrays to lists, showing how slicing and advanced indexing can share or copy data, and how the base attribute reveals views.
Learn to read a CSV into a numpy array using loadtxt, handle comma delimiters and missing values, inspect a 7750 by 14 dataset of year, day, temperatures from 1772.
Strip the first two columns to keep only temperatures. Filter out the minus nine nine nines markers with boolean masking and flatten to a 1-D array.
Explore vectorized numpy operations to convert tenths of a degree to degrees Celsius and compute the min, max, and mean temperatures, with dtype as float and formatted output using f-strings.
Explore grouping temperatures with numpy histogram, using data arrays and the default ten bins to obtain the histogram and bin edges, and prepare for plotting with matplotlib.
Plot a histogram of temperatures using NumPy and Matplotlib, showing how bin edges, histogram data, and broadcasting issues affect the visualization.
Understand how numpy translates paper equations into code by sampling x values with np.arange and np.linspace, enabling plot-ready expressions like y = sin(x) - a over x.
Utilize NumPy vectorization to compute y = sin(x - a)/x for x from -10 to 10, and plot an animation showing how y changes as a varies with matplotlib.
Finally, explore the NumPy api reference and discover tools that save you from building from scratch. Embrace vectorized programming with the ndarray mindset.
This is a concise course that covers the fundamentals of Python's NumPy package. Most students who learn NumPy for the first time say that it feels different from the core Python they learnt. And they're right.
NumPy requires a different mindset. There's a reason why NumPy does things differently and if you understand why things are the way they are in NumPy, the rest of your NumPy journey will be easier.
This course doesn't try to cover everything in the NumPy package. That's impossible and not desirable. Instead, I designed this course to be concise and to focus on what really matters:
Understanding the core topics in NumPy
Understanding the NumPy mindset
This course covers the following topics:
NumPy's main data structure, the ndarray
Vectorisation in NumPy
Arrays in higher dimensions
The basics of broadcasting
Filtering NumPy arrays using Boolean operations and Boolean indexing
Reading external data using NumPy
Representing equations with NumPy
And of course, throughout the whole course you'll get familiar with the NumPy mindset.
---
About me, your instructor
I've been teaching Python and NumPy for a decade. Before that, I worked as a physicist and used numerical and scientific programming in my research work for over a decade.
My focus is on communicating clearly, in a friendly and relaxed manner. I'm the author of the The Python Coding Book (you can ask Google for a "python book" and you'll find this book as one of the first entries) and I have taught Python to individuals and corporations around the world.
And I'm approachable. You can ask me questions and I'll always reply, whether here on social media or anywhere else you can find me!