Python for Data course menu
Introduction to Data Analysis With Python (NumPy, pandas, matplotlib)
What data analysis is, the steps of a typical analysis, why Python is the most used language for it, and the libraries you will learn in this course: NumPy, pandas, matplotlib, seaborn and SciPy.
On this page
Data analysis means turning raw data into answers: which product sells best, whether a new web page converts better, why costs rose last quarter. Python is the most widely used language for this work because it is easy to read and has excellent libraries for every step.
A first taste#
Here is a complete small analysis: load some sales, summarise them by region, and find the best month. Do not worry about the details yet; every line is explained later in the course.
import pandas as pd
sales = pd.DataFrame({
"month": ["Jan", "Jan", "Feb", "Feb", "Mar", "Mar"],
"region": ["North", "South", "North", "South", "North", "South"],
"amount": [1200, 950, 1430, 1010, 1580, 1300],
})
print(sales.groupby("region")["amount"].sum())
print()
by_month = sales.groupby("month", sort=False)["amount"].sum()
print(by_month)
print("Best month:", by_month.idxmax())region
North 4210
South 3260
Name: amount, dtype: int64
month
Jan 2150
Feb 2440
Mar 2880
Name: amount, dtype: int64
Best month: MarSix lines of real work answered two business questions. With a million rows instead of six, the code would be the same.
The steps of an analysis#
Most analyses follow the same path:
- Ask a question. "Which region grew fastest?" is answerable; "look at the data" is not.
- Collect and load the data: CSV and Excel files, databases (SQL), APIs.
- Clean it: missing values, wrong types, duplicates, typos. This often takes most of the time.
- Explore and analyse: summaries, groupings, comparisons, statistics.
- Visualise the findings with charts.
- Communicate the answer clearly, including its limits.
The libraries#
They work together: pandas stores its columns as NumPy arrays, and matplotlib draws pandas data directly.
What you need first#
You should be comfortable with basic Python: variables, lists, dictionaries, loops and functions. If not, take the Python course first; it will make this one much easier.
Knowing some SQL helps too: grouping, filtering and joining in pandas follow the same ideas as GROUP BY, WHERE and JOIN.
How this course works#
Every example shows the real output it produces, checked by running it. The examples were run with Python 3.13, NumPy 2.3, pandas 2.3, matplotlib 3.10, seaborn 0.13 and SciPy 1.16. Older versions print the same results for almost everything in this course; where a recent change matters, the lesson says so.
Charts in the lessons are generated by running exactly the code shown above them.
Key takeaway#
Next, set up your computer in Installing the Tools.
Finished this lesson?