On this page
Session 1 · Load, inspect and transform
Exam focus. Use the full load-to-export workflow, choose transformations by their assumptions, and explain what happens to invalid inputs.
What to know
Load, inspect, convert, transform, then export. Check whether the data describe one entity over time, multiple entities at one time, or multiple entities over time.
Code pattern
import pandas as pd
import numpy as np
df = pd.read_csv("energy.csv")
print(df.head())
df.info()
value = pd.to_numeric(df["Consumption_MWh"], errors="coerce")
df["Log_Consumption"] = np.log(value.where(value > 0))
df.to_csv("cleaned_energy.csv", index=False)
Exam traps
Coercion turns invalid entries into missing values without dropping rows. Logarithms require positive inputs. Min–max scaling divides by max minus min, which needs a nonzero range.
Write an interpretation
State the result, explain what produced it, and say why it matters for the decision in the case.
Source: Data Handling Final Revision File and the exam announcement and mock supplied in chat.
Exam methods and worked application
| Task | Code pattern | Check before trusting the result |
|---|---|---|
| Load | pd.read_csv(...) or pd.read_excel(...) | Verify file, headers and rows |
| Inspect | head(), info(), dtypes, isna().sum(), describe() | Preview values, types, missingness and distribution |
| Convert | pd.to_numeric(x, errors="coerce") | Count newly missing values and investigate units or commas |
| Export | to_csv(..., index=False) or to_excel(..., index=False) | Keep intended columns and avoid exporting an artificial index |
Transformation reference
| Operation | Formula or syntax | Interpretation and guard |
|---|---|---|
| Daily return | 100 * (close - open) / open | Percentage relative to opening price. Opening price must be nonzero. |
| High–low spread | 100 * (high - low) / ((high + low) / 2) | Trading range relative to midpoint. Check midpoint. |
| Min–max scaling | (x - x.min()) / (x.max() - x.min()) | Rescales observed extrema to 0 and 1. A constant column has a zero range. |
| Log | np.log(x.where(x > 0)) | Compresses positive large values. Nonpositive inputs need explicit handling. |
| Clip | x.clip(lower, upper) | Caps extremes and keeps all rows. Explain threshold selection. |
Worked exam application
A quote opens at 80, closes at 84 and has a low of 78 and high of 86. The return is 5%. The high–low spread is 8 ÷ 82 × 100 ≈ 9.76%. These describe different things: a net price move and an intraday range.df.info() already prints its report and returns None; call it directly. If you have chronological cash movements, use cumsum() on signed changes and add opening cash. Sorting can change intermediate balances while preserving the final sum.
Official guide · Import, functions and missing data
The guide confirms 120 minutes, eight one-point MCQs and 11 open-ended questions across Sessions 1–4. Practice short code, code correction and reasoning. Use plan → code → justify. Warm-up and end-of-session quizzes are useful MCQ practice. The guide also names the Session 2 indentation quiz.
Use Pandas and NumPy, import files, define simple functions and explain missing-data handling. Example: use pd.read_excel(path, sheet_name=...) for a named worksheet. A small function such as def net(amount, fee): return amount - fee converts an input into a reusable output. Check missingness before replacing it, and explain why the replacement is appropriate.
Official Exam Preparation Guidelines (pp. 1–3).