Climate Data Analysis with Pandas and Matplotlib
By: Francis Narteh Ocansey
Tags: Temperature, Pandas, Data Science, Matplotlib, Climate Change

Climate Data Analysis with Pandas and Matplotlib

Photo by Dawid Zawiła on Unsplash

The Rationale

An Exploratory Data Analysis (EDA) of Climate data from Ghana, showcases my first project portfolio into data science. Climate data provides a time series of weather variables record, in indexed time order and very useful for an EDA. Secondly, it is freely available publicly and in my case, the data was obtained from https://www.ncdc.noaa.gov/cdo-web after just a few clicks.

Taking a cue from the NOAA hottest month on record project from https://www.ncdc.noaa.gov/sotc/global/201904. I delve into an EDA of Ghana’s climate data using Pandas and Matplotlib to understand the trends and how it compares to the global climate change phenomena. And personally, get a grip on the climate change mantra from the local perspective. The article presents the results of the project and a bit of the journey.

The Journey

Over the past few months, I have plunged myself into learning Python programming to cover up on my spare time due to a slowdown in work due to the Covid 19 pandemic. Numerous freely available resources on the internet have been helpful in my self-study for this subject. Of particular mention is the complete course on Geo-python offered by the University of Helsinki. This is for learners trending in the environment and natural resources field. Others include Corey Shafer’s tutorials on youtube and worth of tips offered on StackOverflow.

Interestingly while setting up my Github account to host the project, I run into a big surprise. Github informed me my email account is already taken, what a surprise! I did a password retrieval which was successful. Only when I accessed the account did I realized, the account was the first set up in 2014, wow! Indeed, it has been long in coming.

Results

The data were records obtained from 17 stations/towns spread across Ghana. It contained 11 variables of 70,068 daily records. The records start from 1973 to 2020, a period of 47 years of climate data. The length of unique records varied across the stations and this in no way affects the global analysis of the data. Only four main variables were eventually selected for the analysis.

Summary and brief commentary below;

The mean daily temperature of Ghana is 27.6 oC i.e., average daily temperature. The maximum mean daily temperature of 35.0 oC, recorded on 22–04–1977 — Hottest day. Consistent with global April hottest month record. Maximum mean monthly temperature 31.1 oC, recorded in April 1983 — Hottest month. Maximum mean yearly temperature 30.2 oC, recorded in 1983 — Hottest year. This diverges from the year 2020 that tied with 2016 as the hottest year globally according to NASA.

Yearly Mean Temperature, Ghana by Francis N. Ocansey

The yearly mean temperature graph shows a generally rising and fluctuating temperature that plateaus around 28oC from 2015. This denotes more hotter days with severe climate implications. In 1983 Ghana experienced its worst drought and bushfires in history, accurately captured in the visuals.

Over the period, the records show a decadal increment of 1.5oC in temperature since 1973. The best period to visit Ghana is between mid-June and September when temperatures fall below 26oC, our coolest months.

Monthly Mean Temperatures, Ghana by Francis N. Ocansey

One major takeaway about coding with Pandas is to sort your dataframe before any slicing operation, otherwise, you may encounter challenges with your analysis. That is if your data is not already sorted. You wouldn’t want to experience the hassle I went through as a newbie doing slicing. Much more analysis, visualization, and deductions could be made from this project considering the type of data set with values from 17 stations. Head to my Github portable to have a play with it. Comments and questions are welcome on this piece. Thanks for reading.