Skip to content

CSV Files (Pandas)

🟨🐍 Technique Card: Reading CSV Files with Pandas (practical)

Skill: Reading and exploring data
You’ll need: Python, Pandas installed (pip install pandas), a .csv file
You’re learning this because: It helps you work with real-world data easily, especially for Digital Changemaker projects.


πŸ” What You’ll Learn

  • How to import pandas
  • How to read a CSV file into a DataFrame
  • How to look at the first few rows
  • How to understand the shape and structure of your data

🧰 Step-by-Step

  1. Import pandas
import pandas as pd
  1. Read a CSV file
    Replace "data.csv" with your own file name.
data = pd.read_csv("data.csv")
  1. Look at the top of the data
    This shows the first 5 rows.
print(data.head())
  1. See how many rows and columns there are
print(data.shape)
  1. See the column names
print(data.columns)
  1. See a summary of the data
    Useful to check numbers and missing values.
print(data.info())

πŸ’‘ Tip

  • Make sure your .csv file is in the same folder as your Python file, or give the full path.
  • If you get encoding errors, try:
pd.read_csv("data.csv", encoding="utf-8")

🎯 Try It Out

Load an example CSV file - create one like the following if you want to keep it simple:

Name,Food,Distance_km
Tom,Apples,150
Sara,Strawberries,600
Ben,Carrots,50

Use the tools given on this technique card to explore the data.


πŸ§ͺ Make It Your Own

  • Use Pandas to work with data from our digital changemakers project idea cards!

πŸ”— Linked Cards

Watch the video