Susan Wanjiku/

Key CBK Indicative Exchange Rates in Kenya Over Time


CBK Exchange Rates in Kenya Since 2016 to 2024


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.

dateThis column contains the specific dates corresponding to each currency entry.
CurrencyIdentifies the different types of currencies in the dataset.
MeanRepresents the average value among the recorded exchange rates.
BuyIndicates the price for purchasing a currency.
SellReflects 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')
# Calculate skewness for each numeric column in the dataset
skewness = cbk_currency_data.skew()
# Calculate kurtosis for each numeric column in the dataset
kurtosis = cbk_currency_data.kurtosis()
# Calculate central tendency measures (mean, median, mode) for each numeric column in the dataset
central_tendency = {
    'Mean': cbk_currency_data.mean(),
    'Median': cbk_currency_data.median(),
    # Mode might return multiple values for each column, hence converting the first mode to string for consistent display
    # Adjusting the mode calculation to ensure it's compatible with DataFrame creation
    'Mode': cbk_currency_data.mode().iloc[0].astype(str)

central_tendency_df = pd.DataFrame(central_tendency)
# 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)


# Display the shape of the cbk_currency_data dataframe

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

Finding NULL values

# Check for missing values in the cbk_currency_data dataframe

  • AI Chat
  • Code