CBK Exchange Rates in Kenya Since 2016 to 2024
Data
Unpacking the Kenyan Shilling's Dance with the Dollar and Beyond
Embarking on an analysis of foreign exchange data sourced directly from the Central Bank of Kenya's website., I obtained the dataset, originally in CSV format but available in various other formats.
The Kenyan shilling, once a proud warrior in the foreign exchange arena, has lately found itself locked in a tango with the ever-powerful US dollar, its steps faltering as the greenback asserts its dominance. This project delves into the intricate world of foreign exchange in Kenya. This dataset serves as a treasure trove, holding within its rows and columns the stories of various currencies' performance against the ever-shifting sands of time.
Column | Description |
---|---|
date | This column contains the specific dates corresponding to each currency entry. |
Currency | Identifies the different types of currencies in the dataset. |
Mean | Represents the average value among the recorded exchange rates. |
Buy | Indicates the price for purchasing a currency. |
Sell | Reflects the price for selling a currency in the market. |
# import necessary libraries
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
cbk_currency_data = pd.read_csv(r'Currency_data.csv')
cbk_currency_data.head()
# Calculate measures of dispersion (range, variance, standard deviation) for each numeric column in the dataset
dispersion = {
'Range': cbk_currency_data.max(numeric_only=True) - cbk_currency_data.min(numeric_only=True),
'Variance': cbk_currency_data.var(),
'Standard Deviation': cbk_currency_data.std()
}
dispersion_df = pd.DataFrame(dispersion)
dispersion_df
DATA PREPROCESSING
# Display the shape of the cbk_currency_data dataframe
cbk_currency_data.shape
The dataset comprises records of everyday currency prices, encompassing the mean, buy, and sell values for various currencies. With 37,877 rows and 5 columns, each row represents a distinct observation capturing currency price information for a particular date. The columns are structured to include the date of observation, the currency type being evaluated, the mean price, the buying price, and the selling price.
# Information about the cbk_currency_data dataframe
cbk_currency_data.info()
Finding NULL values
# Check for missing values in the cbk_currency_data dataframe
cbk_currency_data.isnull().sum()
# Filtering the cbk_currency_data dataframe to show rows where any of the columns have missing values
cbk_currency_data[cbk_currency_data[['Currency', 'Mean', 'Buy', 'Sell']].isnull().any(axis=1)]
Handling Missing Values
# Dropping rows with missing values
cbk_currency_data.dropna(axis=0, inplace=True)