Pulse Data Hub

Data Science in Climate Change: A Python Analysis

Data Science in Climate Change: A Python Analysis

Data science in climate change comes down to a few questions that real data can answer: how fast is the world warming, how does carbon dioxide track it, and how far can a simple model be trusted? This article tests those on two public datasets, NASA’s annual global temperature anomalies and monthly CO2 measured at Mauna Loa, using pandas 3.0.5 and NumPy 2.5.3. We report what a straightforward analysis shows and where it stops.

Bar chart of global warming trend per decade: 1880-1900 0.01, 1900-1950 0.08, 1950-2000 0.11, 1975-2025 0.21, 1990-2025 0.24 degrees C
Straight-line trend in annual global temperature anomaly over different periods.

The data

The temperature series is the GISTEMP annual global mean anomaly, 1880 to 2025 (146 years), from the open datasets/global-temp repository. An anomaly is the difference from a reference period, so 0 is not “no warming”. The same file also holds a second source (NOAA, 1850 to 2026) with a different baseline, so we used only GISTEMP to avoid mixing baselines. The CO2 file holds monthly Mauna Loa averages from March 1958; the annual means we use run from 1959 to 2025 (316.0 ppm in 1959, 427.3 ppm in 2025).

import pandas as pd, numpy as np

t = pd.read_csv('temp.csv')
g = t[t.Source == 'GISTEMP'].set_index('Year').Mean

# warming per decade over different periods
for a, b in [(1880, 1900), (1900, 1950), (1950, 2000), (1975, 2025), (1990, 2025)]:
    s = g.loc[a:b]
    print(a, b, np.polyfit(s.index, s.values, 1)[0] * 10)   # degrees C per decade

How fast is it warming?

Decade averages of the anomaly rose from -0.21 in the 1880s to 0.04 in the 1940s, stayed near zero until the 1970s (0.03), and then climbed: 0.25 in the 1980s, 0.39 in the 1990s, 0.59 in the 2000s, 0.80 in the 2010s and 1.06 so far in the 2020s. A straight line fitted to 1900 to 1950 rises 0.08 degrees per decade, 1950 to 2000 rises 0.11, and 1975 to 2025 rises 0.21, with 1990 to 2025 at 0.24. So the pace in recent decades is about double the mid-century pace. The warmest years in the file are 2024 (1.28), 2025 (1.18), 2023 (1.17), 2016 (1.01) and 2020 (1.00), and all ten warmest years fall in the last 13 years of the record.

Year to year is noisy

Since 1950 a year was warmer than the one before it only 59.2% of the time, and the typical change from one year to the next had a standard deviation of 0.12 degrees. A trend of 0.2 degrees per decade is only 0.02 per year, so single years cannot show a trend; you need decades of data. This is why a cold year is not evidence against warming, and a hot year alone is not proof of it.

Carbon dioxide

CO2 rose by about 1.24 ppm a year over 1959 to 1989 and about 1.99 ppm a year over 1990 to 2019 (linear fits to annual means). Across the 68 years where both series exist (1958 to 2025; 1958 is a partial year starting in March), the correlation between annual CO2 and temperature anomaly is 0.966. That high number comes mostly from both series trending upward over time. When we correlated only the year-to-year changes, the correlation fell to 0.32. A shared trend is not a measurement of cause, which comes from physics and many other kinds of evidence; our analysis only shows the two move together.

A forecasting test: how far can you trust a simple model?

We fitted models on 1960 to 2000 and predicted the 25 years 2001 to 2025, which the models never saw. Mean absolute errors in degrees were:

Model (trained 1960-2000)Error on 2001-2025
Mean of the training years0.632
Mean of the last 5 training years0.360
Straight line through time0.171
Curved (quadratic) line through time0.078
Linear model on measured CO20.083

Ignoring the trend is badly wrong (0.632). A straight line underestimates the later acceleration (0.171). A quadratic fit and a model that uses the CO2 measurement both did well (0.078 and 0.083). Read this carefully. The quadratic worked here because the acceleration continued, and extrapolating polynomials far beyond the data is risky in general. The CO2 model needed CO2 values for the test years, which are observations, so it shows a relationship holds rather than forecasting the future. This is a toy test, not a climate model; real projections use physics-based simulations.

What this means for data science work

Public climate series are clean, long and well documented, which makes them good practice: the main skills are choosing a baseline, avoiding mixing sources, separating trend from noise and not over-reading correlations. If you want the same workflow on other data, see time series analysis in Python, linear regression in Python and the overview of data science by industry.

Limits of this analysis

Global annual averages hide regional differences; linear fits are rough summaries of non-linear change; the baseline of the GISTEMP anomalies (we believe 1951 to 1980, per the dataset documentation, which we did not re-verify) matters for absolute values; and the CO2 file is a single station. Check current values at the original sources before citing figures.

FAQ

How is data science used in climate change research?

Mainly to clean and combine observations, estimate trends, quantify uncertainty and test models against held-out data, as in the forecasting test above.

How fast is the planet warming according to this data?

About 0.21 degrees per decade over 1975 to 2025 in the GISTEMP series, roughly double the 0.08 to 0.11 of 1900 to 2000.

Does correlation between CO2 and temperature prove causation?

No. Our correlation of 0.966 is mostly a shared upward trend, and the year-to-year correlation was only 0.32. Causal conclusions rely on physical understanding and other evidence.

Can I run this myself?

Yes, both files are public and the code above runs in a few lines of pandas.

Newsletter Signup Form

Latest tutorials

Latest articles

On this page
Verified by MonsterInsights