Data Analysis with NumPy
On this page
Data analysis begins with numbers — and in Python, numbers live most efficiently inside NumPy. NumPy, short for Numerical Python, is the foundation of scientific computing in Python. It provides fast, efficient tools to store and process numerical data — from simple lists of numbers to large multidimensional datasets.
Every other analytical library you’ll encounter in this book, such as Pandas, SciPy, and scikit-learn, builds upon NumPy. To master data analysis, you must first understand how NumPy represents and manipulates numerical information.
In this chapter, we explore arrays, perform mathematical and statistical operations, visualize data, and finally apply these skills in a small real-world project. By the end, you’ll see how numerical thinking becomes the foundation of computational reasoning in the humanities.
Installing and Importing NumPy
If you’re using the Anaconda distribution (recommended for data science), NumPy is already installed. Otherwise, you can install it manually using either conda or pip:
conda install numpyor
python -m pip install numpyYou can also visit the official NumPy documentation for more information.
Once installed, NumPy is imported like this:
import numpy as npThe alias np for NumpPy is a universal convention that makes your code shorter and clearer.
The next section introduces NumPy Arrays.