Student Performance Prediction · Foundation · Path B
Tables with pandas: Load, Inspect and Summarise
Load a CSV file into a pandas DataFrame, inspect columns and types, select rows and columns, and calculate summaries by group.
What you need
A computer with a web browser and a free Google account for Google Colab, or Python with Jupyter installed locally. Libraries: pandas, scikit-learn and matplotlib (all free).
In this lesson you will
- Load and inspect a CSV file with pandas
- Select, filter and group data
Key concepts
DataFramecolumndtypefiltergroupbydescribe
The lesson
pandas stores tables as DataFrames. read_csv loads a file; head, info and describe show the first rows, the column types and summary statistics.
Select a column with df['attendance_rate'] and filter rows with a condition, such as df[df['grade'] == 'S3']. groupby summarises by group, for example average scores by school.
Always check the data types: a score column stored as text will not behave like numbers.
Step by step
- Upload the practice CSV to Colab and load it with read_csv.
- Run head, info and describe and note anything surprising.
- Filter students with attendance below 70%.
- Calculate average maths scores by school with groupby.
Practice activity
Answer eight questions about the practice dataset using pandas, each with the code and a one-sentence answer.
Expected result: Correct answers supported by code that runs from top to bottom.
Common mistakes
- Ignoring a column stored as text instead of numbers
- Changing the original DataFrame by accident instead of working on a copy
Check your understanding
-
What does df.info() show?
Show answer
The columns, their data types and how many values are not missing.
-
What does groupby do?
Show answer
Splits the data into groups so summaries can be calculated per group.
Further learning
Projects are instructor-guided: an instructor sets milestones, checks your work and gives feedback, online or in person. Self-study of the public lessons does not lead to a certificate. Enrolment and fees follow the Academy's existing policies — contact the Academy.