Average Temperature Increase
- Jul 30, 2024
- 2 min read

Climate change is a real problem. Rising temperatures are just a small part of it. However, I wanted to start my explorative journey with a small dataset, so I decided to use the Global Land Temperatures from Kaggle.
Recently, I decided to look at an Average Temperature by Country dataset where I analysed the average temperature of different countries around the world. I used just a fraction of the dataset, but I wanted to utilize different python tools such as plotly.express and pandas. My main focus was getting a chloropleth map to show up and a basic time series set up to show the change over time. My colab notebook is linked in the bottom of this blog
import pandas as pd
import matplotlib as mpl
import plotly.express as px
from google.colab import drive
drive.mount('/content/drive')
df = pd.read_csv('/content/drive/My Drive/GlobalLandTemperaturesByCountry.csv')
df.head()
df = df.dropna()
This first code was used to initialize my tools. Not unlike getting a toolbox to start building something, these first lines of code were the building blocks I used to create the visualizations. df is the name of the dataframe, and the .dropna() function is utilized to drop all NaN (Null) values in a dataset.
px.choropleth(df,
locations='Country',
locationmode='country names',
color='AverageTemperature',
hover_name='Country',
color_continuous_scale=px.colors.sequential.Plasma,
title='World Annual Temperatures')
This was the highlight/pinnacle of my code. This code took me quite some time to figure out, as each part took me some time to understand and research. This creates a chloropleth map where the values are highlighted on the map, user has an interactive experience, and there is a key near the side of the chart.
df1 = pd.read_csv('/content/drive/My Drive/GlobalLandTemperaturesByCountry.csv', index_col ="Country")
df1 = df1.loc["United States"]
df1 = pd.read_csv("df1", index_col = "dt")
This code was for a line graph, showing the average temperature fluctuations of the United States. I was able to learn how to utilize the loc attribute as well as isolate certain values using python.
In the end, I was able to utilize my previously learnt data science skills while learning new ones. I learnt how to more effectively use plotly.express, pandas, and the .loc function. I also learnt how Average temperatures have been dangerously rising voer the recent past few years,showcasing an alarming rate of increased temperatures.



Comments