[LV] lucasvieira.tech

Udacity · Data Analyst Nanodegree

Weather Trends

How much warmer is it where I live, compared with the world? Local and global temperatures from 1854 to 2024, step by step.

June 2024 · updated September 2026 · SQL · Python · Excel

Average temperature in 1991–2020 compared with 1854–1900 (the 30-year moving average at 2020, in step 05). Global is the average over land.

What changed in the September 2026 update
  • The steps I did by hand in Excel (continent lookup, moving averages) are now code, in a public repository.
  • The data goes up to 2020 for the cities and 2024 for the global average, straight from Berkeley Earth, the source behind the Udacity database.
  • Two data quality issues are explained: cities with identical series, and years that were incomplete or stored as zero.
  • The main comparison is now the change in temperature, not only its level.

01

The data

In this project, I analyze local and global temperature data and compare the temperature trends where I live with global trends. I also include two more cities: Amsterdam, in the Netherlands, and Dublin, in Ireland, both well regarded among tech professionals in Brazil.

The Udacity workspace had a database with three tables:

city_list

city · country

342 rows

city_data

year · city · country · avg_temp

yearly average per city, °C

global_data

year · avg_temp

yearly global average, °C

The workspace is not public, so I rebuilt the same tables in SQLite with the original source, Berkeley Earth. That way every query on this page can be run again by anyone.

02

What is in the city list

After seeing the schema, I decided to understand the data available by gathering general information, like the different cities and countries.

SELECT COUNT(*)                AS rows,
       COUNT(DISTINCT city)    AS city_names,
       COUNT(DISTINCT country) AS countries
FROM city_list;

There are 342 rows but only 329 city names. A first interesting insight is about duplicate names: if we only queried by city, the data could have been mixed up. That is why every query here filters by city and country.

    Cities by continent

    The database has no continent column. In 2024 I added one in Excel with a list of countries by continent and a VLOOKUP, after fixing 18 country names that were spelled differently in the two lists. Now the same step is a merge in Python, and the counts match the original ones.

    North and South America are counted together. Asia is the most represented continent; Oceania has only 8 cities.

    03

    Brazil on the map

    There are 11 Brazilian cities in the database: 7 in the southeast and south, 3 in the northeast and 1 in the north. The Midwest is not represented. Hover a city to see its numbers.

    Berkeley Earth does not measure each city. It estimates the temperature on a grid that covers the planet, and each city gets the values of the grid point it is assigned to.

    Campinas and Guarulhos share the same point, and so do Colombo and Curitiba. That is why their series are identical, not just similar. In 2024 I explained it by their location; the grid is the real reason.

    SELECT a.city, b.city, COUNT(*) AS years
    FROM city_data a
    JOIN city_data b
      ON a.year = b.year AND a.city < b.city
    WHERE a.country = 'Brazil'
      AND b.country = 'Brazil'
    GROUP BY a.city, b.city
    HAVING SUM(a.avg_temp = b.avg_temp) = COUNT(*);

    Result: Campinas–Guarulhos and Colombo–Curitiba, equal in all 182 years. So the database has 11 Brazilian names but 9 independent series.

    04

    Checking the data before comparing it

    Before plotting anything, I compared my original Udacity exports with the current Berkeley Earth files. Between 1854 and 2012 they move together (correlation above 0.94 for every series), but three things needed fixing.

    Identical series

    Two pairs of Brazilian cities are the same series (step 03). "Campinas" really means the region around São Paulo. It is still the nearest data to where I live, so it stays as my local city.

    Missing years as zero

    In my 2024 spreadsheet, the years without data for Campinas (before 1832 and 1844–1850) were stored as 0. A 0 °C average is impossible for Campinas, so I started the chart in 1854 to leave them out. Now those years are simply left empty, so no calculation can use them by mistake.

    Incomplete years

    The Udacity data stops partway through 2013, so its 2013 average for Campinas misses the warm months and came out 0.5 °C too low. Now a year only counts if it has all 12 months.

    06

    Every Brazilian city

    The same change, for each of the Brazilian cities in the database, against the global average and the other cities.

    07

    Key observations

    The main comparison is the average of 1991–2020 against the average of 1854–1900. In the chart of step 05, that is the 30-year moving average at 2020, in the "Change since 1854–1900" view: the 30 years that end in 2020 are exactly 1991–2020, the latest 30 years with data for every series.

    Shorter windows end higher, because they only average the most recent and hottest years. With a 20-year window, for example, Campinas reaches +1.32 °C in 2020, and with 4 years, +1.59 °C. The hottest years come from the yearly values, with the moving average off. The buttons set the chart for you.

    • Campinas was 1.18 °C warmer in 1991–2020 than in 1854–1900, a bit less than the global land average (+1.34 °C), even though it is about 11 °C hotter in absolute terms. Its 10-year average passed +0.5 °C in 1978 and +1.0 °C in 2002. The hottest years were all recent: 2015 (21.71 °C), 2019 (21.59 °C) and 2014 (21.58 °C).
    • Amsterdam warmed the most of the four, 1.47 °C, and is the only city above the global land average. Its trend since 1970 is also the steepest, 0.35 °C per decade (a linear regression, in section 5 of the notebook). The hottest years: 2014 (11.48 °C), 2020 (11.44 °C) and 2018 (11.13 °C).
    • Dublin warmed 1.18 °C, the same as Campinas, but the two got there differently. Dublin's hottest years came earlier, 2007 (10.27 °C), 2014 (10.23 °C) and 2006 (10.12 °C), and since 1970 it warmed 0.22 °C per decade, the slowest pace of the four (Campinas: 0.23).
    • Global (land) warmed 1.34 °C between the two periods. Its series goes four years further than the cities: 2024 was the hottest year in the record, 2.27 °C above 1854–1900, and the five hottest years were 2024, 2023, 2020, 2016 and 2019. Since 1970 it warmed 0.29 °C per decade, three times its long-term pace (0.97 °C per century since 1854).

    Why did Amsterdam warm more than Campinas?

    A reader in Brazil may find this surprising: Brazil is much hotter than the Netherlands, so the numbers may look wrong at first. But being hotter and warming faster are different things. This analysis compares the change in temperature, not its level.

    The result is consistent with a global climate pattern known as polar amplification: regions at higher latitudes, closer to the poles, tend to warm more and faster than tropical and subtropical regions, such as Southeast Brazil. The effect is strongest in the Arctic and fades towards the equator (Serreze & Barry, 2011). Amsterdam is at 52°N; Campinas is at 23°S.

    Latitude is not the only factor, though. Dublin, even further north (53°N) but on the Atlantic coast, warmed as much as Campinas, likely because the ocean around it warms more slowly than land.

    Over the whole period, the four series rose slowly during most of the 20th century and much faster from around 1980. With a 10-year moving average, all of them passed +1.0 °C between 1995 and 2002.

    The data also reveals potential health risks from more frequent and severe heatwaves, especially for vulnerable groups such as the elderly and children. The world is getting hotter, locally and globally, and the effects need ongoing efforts to be mitigated.

    08

    Limitations and next steps

    • The city series end in 2020, because the city files Berkeley Earth makes available are from a January 2021 release. A source like ERA5 (Copernicus) could extend them to today.
    • The grid points are about 1.6° apart (around 170 km), so each series describes a region, not a city.
    • Yearly averages hide seasons and extremes. Monthly data would allow analysing heatwaves directly.
    • Linking climate change to the carbon credit market and ESG initiatives is still an open idea from 2024.
    • This is an educational project. Running the analysis again with other choices could change the numbers shown here: a different scope (other cities, a whole country instead of one grid point), another baseline period or moving average window, another data source or release, or another way of handling missing data. The choices made here are explained along the page so they can be questioned and changed.

    References

    • Berkeley Earth, land temperature data. berkeleyearth.org/data
    • Udacity, Data Analyst Nanodegree, project "Explore Weather Trends".
    • Statistics Times, countries by continents. statisticstimes.com
    • Natural Earth, country boundaries (1:50m). naturalearthdata.com
    • Serreze, M. C., & Barry, R. G. (2011). Processes and impacts of Arctic amplification: A research synthesis. Global and Planetary Change, 77(1–2), 85–96. sciencedirect.com