Analysis Guide
â Back to OverviewThis guide walks you through analyzing data using Jupyter notebooks. Don't worry if you're new to codingâwe'll take it step by step. By the end, you'll have clean data ready to visualize on your dashboard.
Clone the Repository
Before you can start analyzing, you need to clone the project repository to your computer. This gives you access to the starter Jupyter notebook and any sample data.
# In your terminal, navigate to where you want to work, then run:
git clone [repository-url]
cd wwf-discovery-day
Your coach will share the exact repository URL. If you're using VS Code, you can also clone by clicking "Clone Git Repository" from the welcome screen.
Understanding Jupyter Notebooks
A Jupyter notebook is like a digital lab notebook where you can write notes, run code, and see resultsâall in one place. Think of it as a document that combines:
- Text cells (Markdown) - for explanations and notes
- Code cells (Python) - for running data analysis
- Output cells - for viewing results, charts, and tables
Open VS Code, navigate to your cloned folder, and open the .ipynb file. VS Code will show you a notebook interface where you can run each cell by clicking the play button or pressing Shift+Enter.
Import Your Data
First, you need to load your data into Python. We'll use pandas, a library that makes working with data easy. It's like opening an Excel file, but with code.
# Import the pandas library
import pandas as pd
# Load your data from a CSV file
df = pd.read_csv('data/your-dataset.csv')
# Take a quick look at the first few rows
df.head()
pd.read_csv() reads your CSV file and stores it in a variable called df (short for "dataframe"). The .head() command shows you the first 5 rows so you can see what your data looks like.
Clean Your Data
Real-world data is messy. You might find missing values, duplicates, or inconsistent formatting. Here are some common cleaning steps:
# Check for missing values
df.info()
# Remove rows with missing data
df = df.dropna()
# Remove duplicate rows
df = df.drop_duplicates()
# Rename columns to make them clearer
df = df.rename(columns={'old_name': 'new_name'})
You don't need to clean everything perfectly. Focus on what matters for your dashboard. Missing a few data points? That's okayâjust document it in your dashboard notes.
Analyze with Python
Now for the fun partâfinding insights! Here are some simple analysis techniques:
# Get summary statistics
df.describe()
# Count values in a column
df['column_name'].value_counts()
# Calculate the average
df['column_name'].mean()
# Group data and calculate totals
df.groupby('category')['value'].sum()
What are you curious about? Which region has the highest biodiversity? How has deforestation changed over time? Let your research questions guide your analysis.
Analyze with GreenPT (Optional)
GreenPT is an AI tool that can help you analyze text data qualitativelyâlike identifying themes in survey responses or extracting key information from documents.
# Set up your API key (ask your coach for this)
import openai
openai.api_key = 'your-api-key-here'
# Example: Ask GreenPT to summarize text
response = openai.ChatCompletion.create(
model="gpt-4",
messages=[{"role": "user", "content": "Summarize this: ..."}]
)
print(response.choices[0].message.content)
Use GreenPT when you have text data (like reports or survey responses) and need help categorizing, summarizing, or extracting insights. It's like having an AI research assistant.
Save Your Results to CSV
Once you've cleaned and analyzed your data, save it as a CSV file. This file will be used to create visualizations on your dashboard.
# Save your cleaned/analyzed data
df.to_csv('output/cleaned-data.csv', index=False)
# Save a specific analysis result
summary_df = df.groupby('region')['biodiversity_score'].mean()
summary_df.to_csv('output/region-summary.csv')
Create an output folder to keep your CSV files organized. Give them descriptive names like forest-loss-2020-2024.csv so you remember what each file contains.
Ready to Build!
Congratulations! You now have clean, analyzed data saved as CSV files. You're ready to move on to the Build phase, where you'll use GitHub Copilot to create your dashboard website.
Your CSV files are the bridge between analysis and visualization. Make sure they're well-organized and documented. When you start building your dashboard, you'll reference these files to create charts and display key figures.