
In the face of growing concerns about climate change, it is essential to analyze reliable data to understand trends and project potential future impacts. In this article, we explore global temperature anomalies using Python and open-source data from NASA’s Goddard Institute for Space Studies (GISS). By leveraging Python’s powerful libraries, we will dive into temperature trends from 2002 to the present.
The Dataset: NASA’s Global Temperature Anomalies
For this analysis, we used data from the NASA GISS Surface Temperature Analysis (GISTEMP), which is publicly available at (https://data.giss.nasa.gov/gistemp/). The specific file we used is: “GLB.Ts+dSST.csv”.
What Is the GISTEMP Dataset?
The GISTEMP dataset provides global temperature anomalies, which are deviations from a long-term average temperature. This data combines land surface air temperatures with sea surface water temperatures to present a comprehensive picture of global climate trends.
Global Mean Temperature Anomalies: Annual temperature anomalies relative to the baseline period.
Seasonal Temperature Anomalies:
Winter (DJF): December, January, February
Spring (MAM): March, April, May
Summer (JJA): June, July, August
Autumn (SON): September, October, November
Python Data Analysis: Preparing the Data
The first step was to load and clean the dataset. This involved handling missing values and ensuring that the data was in a suitable format for analysis.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
# Load the dataset downloaded from NASA’s GISS website
data = pd.read_csv(‘GLB.Ts+dSST.csv’, skiprows=1)
# Clean the data
data.replace(‘*******’, pd.NA, inplace=True)
data.dropna(inplace=True)
data[‘Year’] = pd.to_numeric(data[‘Year’], errors=’coerce’)
data[‘J-D’] = pd.to_numeric(data[‘J-D’], errors=’coerce’)
The dataset contains monthly, seasonal, and annual temperature anomalies. We cleaned the dataset by removing rows with missing values and converting relevant columns to numeric types.
Analyzing Global Annual Temperature Anomalies
To identify long-term trends, we applied Linear Regression to the annual temperature anomalies (J-D). This analysis helps us understand whether global temperatures have been increasing, decreasing, or remaining stable over the last two decades.
#Applying Linear Regression
years = data[‘Year’].values.reshape(-1, 1)
temperature_anomaly = data[‘J-D’].values
# Fit a linear regression model
linear_model = LinearRegression()
linear_model.fit(years, temperature_anomaly)
# Generate predictions for the trend line
years_range = np.linspace(years.min(), years.max(), 300).reshape(-1, 1)
Visualizing Global Temperature Trends
Here’s a plot showing the global annual temperature anomalies along with the fitted trend line.
The positive slope of 0.0197 indicates that global temperatures have been steadily increasing since 2002. The intercept suggests where the trend line would intersect if projected backward. This analysis confirms that the Earth has been experiencing a warming trend over the last two decades, likely driven by human activities and greenhouse gas emissions.
Seasonal Temperature Anomalies Analysis
Understanding how different seasons have been impacted by climate change can provide insights into its effects on ecosystems, agriculture, and human health. To explore this, we analyzed temperature anomalies for each season.
#Seasonal Trends
seasons = [‘DJF’, ‘MAM’, ‘JJA’, ‘SON’]
for season in seasons:
season_data = data[season].dropna()
season_years = data[‘Year’][season_data.index].values.reshape(-1, 1)
season_anomaly = season_data.values
# Fit linear regression for each season
season_model = LinearRegression()
season_model.fit(season_years, season_anomaly)
Visualizing Seasonal Trends
Below are the plots for each season with their respective linear trend lines:
1.Winter (DJF)
The slope of 0.0155 indicates a gradual increase in winter temperatures. This warming could lead to shorter winters and reduced snow cover.
2. Spring (MAM)
Spring temperatures have been rising with a slope of 0.0201. This trend can impact agricultural cycles, potentially leading to earlier blooms and harvests.
3. Summer (JJA)
Summers show the steepest increase with a slope of 0.0219. Hotter summers may lead to more frequent heatwaves, affecting human health and energy consumption.
4. Autumn (SON)
The slope of 0.0203 suggests warmer autumns, which can extend the growing season but also delay necessary frost for some crops.
Key Insights
- Global Warming Confirmed: The analysis shows a clear warming trend, with global temperatures rising steadily since 2002.
- Seasonal Differences: While all seasons show an upward trend, summer temperatures are increasing the fastest, which could have serious implications for ecosystems, human health, and agriculture.
- Data-Driven Approach: Leveraging open-source data from NASA and Python’s analytical capabilities provides a powerful way to study climate change.
Tools and Libraries Used
- Pandas: Data manipulation
- Matplotlib: Visualization
- Scikit-learn: Linear Regression
Data Source
NASA GISS Surface Temperature Analysis (GISTEMP)
Conclusion
The analysis shows that temperatures have been rising across the globe, with summers experiencing the most significant increases. This trend, if continued, could have severe implications for ecosystems, economies, and human well-being. Leveraging publicly available data and Python’s analytical capabilities, we can uncover insights that help us better understand and address climate change.
—
This post was previously published on medium.com.
***
Does dating ever feel challenging, awkward or frustrating?
Turn Your Dating Life into a WOW! with our new classes and live coaching.
Click here for more info or to buy with special launch pricing!
***
—–
Photo credit: NASA on Unsplash

