Skip to main content
Everything you’ve learned so far — APIs, pandas, matplotlib, project structure, virtual environments — comes together in this project. You’ll fetch a full week of historical weather data from the Open-Meteo API (free, no key required), load it into a DataFrame, compute statistics, produce a visualization, and save both the chart and the raw data to disk. This is exactly the kind of end-to-end data analysis workflow you’ll use in real-world Python and AI projects.

Project setup

Before writing any analysis code, you’ll create a clean, isolated project environment using uv.
1

Initialize the project

2

Create the folder structure

A clean layout keeps your source code, data files, and outputs organized:
Create the folders and move the default script:
3

Install dependencies

This creates .venv automatically and locks exact package versions in uv.lock for reproducibility.

Fetch 7 days of weather data

The Open-Meteo API provides historical weather data with no authentication required. The following code calculates the date range and builds the request URL dynamically:

Load the data into pandas

Organize the API response into a structured DataFrame:
You’ll see output like:

Visualize the data

Create a line chart showing max, min, and average temperature over the week:

Save the data to CSV

Complete example

Here’s the full script in one place, ready to run from the src/ directory:
Run the script from the project root:

What you’ve accomplished

Look at what this project brings together:
  • Real API integration — fetching live data from a public HTTP endpoint
  • Date arithmetic — computing dynamic date ranges with datetime and timedelta
  • Data processing — reshaping and enriching a DataFrame with pandas
  • Visualization — producing a multi-series chart with matplotlib
  • File handling — creating directories and saving CSV and image files
  • Project structure — organized folders, a virtual environment, and locked dependencies
This is exactly how data analysis and AI projects work in the real world.
Try modifying the script to fetch weather for your own city. Look up your coordinates at latlong.net and update the latitude and longitude values in the URL.

What’s next?

Now that you’ve built and organized a complete Python project, the next step is creating interactive web interfaces and AI dashboards using Streamlit.

Building UIs with Streamlit

Create interactive web applications and AI dashboards