The Impact of Precipitations and Temperature on Coffee prices: Brazil
- Marco Simonetti
- 20 nov
- Tempo di lettura: 4 min
Have you ever wondered if the weather can really move the price of the coffee you drink?
Spoiler: it can – at least partly.
And in my project I show how, using real data and fully commented Python code, written so clearly that even a beginner can follow it step by step.
From Weather to Coffee Prices: What I Actually Did
The idea is simple:
Look at weather in Brazil’s main Arabica coffee regions– São Paulo, Belo Horizonte and Varginha (the Brazilian coffee belt).
Look at Arabica coffee futures prices (ICE Contract KC=F)
Look at the BRL/USD exchange rate
Ask:
When the weather changes today, do prices react about 40 days later?
Why 40 days? Because a hot, dry spell doesn’t change the crop overnight. It changes expectations about yields and supply in the coming weeks. I approximate that delay by shifting the futures prices 40 days forward: today’s weather is matched with the futures price observed 40 days later.
All the details, tables and figures are in the attached PDF, which walks through the reasoning and the results.
Data: Everything Is Open and Downloadable
At the beginning, I struggled to find good data on spot (physical) coffee prices and local weather in the producing regions.
Then something clicked: instead of chasing imperfect spot series, I could use coffee futures prices as a proxy for the underlying coffee price. Futures data are easy to download, updated daily, and freely accessible. By contrast, physical prices vary a lot from region to region, and when they are available they are usually reported at monthly frequency rather than daily. Using futures solved both problems: it gave me a clean, high-frequency price series that is directly linked to market expectations about coffee.
To keep the project accessible, I use only free, public sources:
Meteostat for weather
Daily average temperature and precipitation
For three locations: São Paulo, Belo Horizonte, Varginha
From January 2021 onwards
yfinance (Yahoo Finance) for market data
Arabica coffee futures (KC=F)
BRL/USD exchange rate (BRL=X)
Then, in Python, I:
Load the three weather CSVs.
Clean the dates and set them as a time index.
Build regional averages of temperature and precipitation.
Download futures and FX data via yfinance.
Convert futures prices from USD to BRL using the exchange rate.
Shift the futures series 40 days forward.
Merge everything into one tidy dataset.
Run a simple OLS regression and create some visualizations.
And this is important:
In the code (shown and explained in the PDF), I write everything step by step, with comments like:
# 1. Load weather data
# 2. Clean and merge stations
# 3. Download futures and FX
# 4. Shift prices 40 days forward
# 5. Run regression and plot results
The goal is that even someone new to Python and data analysis can open the notebook and follow the logic line by line.
So… What Actually Drives Coffee Prices?
Temperature: clearly important
Higher average temperature in Brazil’s coffee belt is associated with higher Arabica futures prices 40 days later.
This makes economic sense:
More heat → higher risk of plant stress and reduced yields → markets price in tighter supply → higher futures prices.
This effect shows up both when prices are expressed in BRL and when they are expressed in USD.
Precipitation: not “visible” in this simple model
Daily precipitation (regional average) does not come out as statistically significant in the regression.
That does not mean “rain doesn’t matter for coffee” – obviously it does.It means that, in this very simple setup:
The effect of rain is non-linear (too much and too little are both bad).
Markets probably react more to cumulative rainfall, seasonal anomalies and extreme events, not to millimetres of rain on an average day.
We are averaging across three locations, which smooths out local extremes.
When you squeeze all that complexity into a single daily linear rainfall term, the signal is diluted and the coefficient looks basically like zero.
Exchange Rate: a massive driver
The BRL/USD exchange rate shows a very strong effect, especially for prices in BRL.
When the Brazilian real depreciates (you need more BRL for 1 USD), BRL-denominated coffee prices jump.
That’s exactly what you’d expect: coffee is priced in USD; when the local currency weakens, the same USD price turns into more BRL.
For Brazilian producers and local investors, currency risk is almost as important as the physical risk from weather.
Why This Project Matters (Beyond the Numbers)
The model itself is intentionally simple:
One horizon (40 days ahead),
A linear regression,
Three main variables: temperature, precipitation, exchange rate.
But that’s the point. It shows that:
With open data and basic Python tools, you can already see a meaningful link between local weather in Brazil and global coffee prices.
The climate–currency combo is crucial for anyone who earns or hedges in BRL.
A fully commented notebook can act as both a research exercise and a hands-on tutorial in data, markets and econometrics.
All the nitty-gritty – code, tables, charts, regression outputs – is explained in the attached PDF, where each step of the pipeline is documented so that even a beginner can understand what happens from raw CSV to final regression.
And Next?
This work is just a starting point. From here, you could:
Use better rainfall metrics (e.g. 14-day cumulative rain, drought indices, anomalies vs seasonal averages).
Add non-linear terms and interactions (temperature × rainfall, squared terms, thresholds).
Move to dynamic models, letting weather today affect prices at multiple horizons.
But the core message is already clear:
With a bit of Python and open data, you can literally watch how the sky over Brazil shows up in the price of coffee – and you don’t need to be a quant to follow the code.


Commenti