Hiring Partners
Segilola Resources Operating LimitedTaviatech TechnologiesFCMBMTN NigeriaAdvans La Fayette Microfinance BankAboki AfricaFirst Bank of NigeriaOPay
← Machine Learning for Finance & Accounting Level Two Β· Lesson 2 of 9

Module One

πŸ“– Every lesson in this course is free to read right here, no account needed. Create a free account to track your progress, take the exam, and earn your certificate.
2
Module 1: Python for Financial ML – Data Wrangling Essentials for Young Coders
⭐ Module 1 · Level Two

Python for Financial ML:
Data Wrangling Essentials

🐍 Tame messy money data before the model even starts

🎯 What you'll learn in this module

  • βœ” How to use Pandas to load, merge, and reshape financial data
  • βœ” How to clean messy financial datasets (missing values, weird types, duplicates)
  • βœ” How to work with dates, currencies, and periods
  • βœ” How to visualize financial data quickly and clearly
  • βœ” How to organize notebooks and keep your work reproducible
  • βœ” The most common data quality traps in finance β€” and how to avoid them
🐼
Pandas: The Swiss Army Knife for Financial Data
The Big Idea

Pandas is the most popular Python library for working with tabular data. Think of it as Excel, but programmable, faster with big datasets, and able to repeat the same steps a million times without getting tired.

Its two stars are the DataFrame (a table with rows and columns) and the Series (a single column). Almost everything you do in finance β€” loading bank statements, combining ledgers, aggregating monthly totals β€” can be done in Pandas in just a few lines.

πŸ—‚οΈ Excel is a hand‑drawn chart. Pandas is a spreadsheet robot that can do the same chart in 1,000 spreadsheets in one second.
πŸ“₯
Loading Financial Data from Anywhere
Loading

Financial data comes in many shapes. Pandas can read them all:

Format Function Common Use
CSV pd.read_csv() Bank exports, ledger extracts
Excel pd.read_excel() Monthly reports, statements
JSON pd.read_json()
SQL pd.read_sql() Direct from databases
πŸ”Œ Pandas can plug into almost any data source β€” like a universal charger.
🧽
Cleaning Messy Financial Datasets
Cleanup

Real financial data is never perfect. You'll see:

Missing values (a transaction with no amount β€” oops). Wrong types (a price stored as text). Duplicates (the same row twice from a merge). Inconsistent formats ("$1,234.56" vs "1234.56" vs "1.234,56").

Pandas gives you clear tools: df.dropna(), df.fillna(), df.astype(), df.drop_duplicates(). The rule: clean slowly, document every step.

🧹 Cleaning data is like tidying a room after a party. You don't throw everything out β€” you find what's valuable and set aside what's spoiled.
πŸ“…
Dates, Currencies & Periods
Data Types

Financial data always has a date β€” but dates arrive in many formats: "2024-01-15," "15/01/2024," "Jan 15, 2024." Pandas converts them all with pd.to_datetime(). Once dates are real dates, you can filter by month, group by quarter, and compute "days since last payment."

Currencies need care too: which currency is this amount in? Was it converted on which date? Store amounts alongside their currency, and be careful with conversions. Never mix currencies without a clear exchange rate.

🌍 A number without a date or currency is like a photo without a location tag β€” you can't tell where or when it belongs.
πŸ“Š
Quick Financial Data Visualization
Visualize

Before you build any model, look at your data. Visualization catches problems instantly: gaps, spikes, flatlines, or suspicious clusters.

Simple charts go a long way: line plots for trends over time, bar charts for category comparisons, scatter plots for two features, histograms for distribution. Pandas can plot quickly with df.plot(), and libraries like Matplotlib and Seaborn add polish.

πŸ”¬ A chart is a microscope for your data. It reveals the tiny bugs before they become big problems.
πŸ““
Notebooks & Reproducible Analysis
Workflow

You'll write your analysis in Jupyter Notebooks (or Google Colab). These let you mix code, output, and notes in one place. But there's a catch: a notebook run out of order gives wrong results.

Best practices: restart & run all before sharing, save cleaned data as a separate file, and version your work (Git). When someone asks "how did you get this number?" β€” you should be able to point to a single cell and reproduce it.

🍳 A well‑organized recipe lets anyone cook the same dish. A well‑organized notebook lets anyone reproduce your analysis.
🚨
Common Data Quality Pitfalls
Danger

Some traps catch nearly every financial analyst at least once:

Silent type conversion: a number stored as text won't sum correctly. Mixed date formats: half the rows in one format, half in another. Missing currency: you mix dollars and euros. Trailing spaces: "ACME" β‰  "ACME ". Hidden characters from spreadsheet exports.

Pandas helps you catch these with df.info(), df.describe(), and df.isna().sum(). Always check before you trust.

πŸ—οΈ A building is only as strong as its foundation. A model is only as good as its data.
πŸ“₯ Load
β†’
🧽 Clean
β†’
πŸ“… Format dates
β†’
πŸ“Š Visualize
β†’
βœ… Ready for ML
⚠️ The most expensive mistake: Not checking your data before modeling. A model trained on a mis‑typed "amount" column could produce predictions that quietly ruin budgets or mislead management. Always inspect data first β€” half of ML success is just clean data.

πŸ› οΈ Hands-on activities (no boring stuff!)

1

Load a mini bank statement: Create a small CSV with 10 transactions (date, description, amount). Load it into Pandas. Print the first 5 rows and check the column types with df.info().

2

Clean the mess: Introduce 2 missing values and 1 duplicate into your dataset. Use df.dropna() and df.drop_duplicates() to clean it. Compare the row counts before and after.

3

Date practice: Add a "date" column with mixed formats ("2024-01-15" and "15/01/2024"). Convert them all with pd.to_datetime(). Then group your transactions by month and print total spending per month.

4

Visualize a trend: Plot your transactions over time as a line chart. What do you notice? Are there any gaps, spikes, or missing days? Write one sentence describing what you see.

5

Detective mode: Check your dataset for common pitfalls: any strings where numbers should be? Any trailing spaces in names? Any missing currencies? Write a 3‑line summary of what you found.

6

Reproducibility check: In your notebook, restart the kernel and run all cells from top to bottom. Does everything work? If not, clean up the order β€” every analysis should run top‑to‑bottom cleanly.

πŸ†

By the end of this module, you'll be able to: load financial data in Pandas, clean messy datasets, handle dates and currencies, visualize trends, organize notebooks reproducibly, and spot common data quality traps before they cause trouble.

πŸ† Get Certified

πŸ”’

Earn this certificate

Every lesson is already free to read. Sign up, finish the lessons, pass the exam (₦2,000 or 20,000 coins), and get a verified certificate with your name on it.

πŸŽ“ Sign Up to Get Certified
πŸ› οΈ Practice Tools
Hands-on simulators & labs - subscription required.
β†’
🎯 Internship Tasks
Real-world tasks to build your portfolio - unlock them with a subscription.
β†’