Malaria in Nigeria Analysis using Python Programming

Analysis of Nigeria Malaria was done using the Indicator Survey (NMIS) dataset to perform some descriptive analysis using python programming.

Malaria in Nigeria

Malaria is endemic in Nigeria and remains a major public health problem, taking its greatest toll on children under age 5 and pregnant women, although it is preventable, treatable, and curable. Africa still bears over 80 percent of the global malaria burden, and Nigeria accounts for about 29 percent of this burden. Moreover, in combination with the Democratic Republic of Congo, Nigeria contributes up to 40 percent of the global burden (World Malaria Report 2014). In Nigeria, malaria is responsible for approximately 60 percent of outpatient visits and 30 percent of admissions.

Application of Python Programming

To begin we are going to load in the required python packages and dataset. We are going to perform some data cleaning and descriptive analysis afterward.

The following codes are executed using Jupyter notebook and the dataset used can be download here: GET IT

# perform necessary import
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import numpy.random as nr
import math
%matplotlib inline

Execute the code in the cell below to load the dataset and print the first few rows of the data frame.

# load datasets Malaria = pd.read_csv('Nigeria Malaria Survey.csv') 

The column names in the dataset have coded names. We are going to assign human-readable names to the columns and print shape and head of the data.

Malaria = pd.read_csv('Nigeria Malaria Survey.csv')
Malaria.columns=['Case Identification', 'Region', 'Type of Place of Residence', 'Source of Drinking Water', 'Type of Toilet Facility',
                'Has Electricity', 'Main Floor Material', 'Main Wall Material', 'Main Roof Material', 'Has Bicycle', 'Has Motorcycle/Scooter',
                'Has Car/Truck', 'Has Mosquito Bed Net for Sleeping', 'Owns Land Suitable for Agriculture', 'Has Bank Account', 
                'Wealth Index', 'Cost of Treatment for Fever', 'State']


Notice that some of the column names contain the ‘/’ character. Python will not correctly recognize character strings containing ‘-‘. Rather, such a name will be recognized as two character strings. The same problem will occur with column values containing many special characters including, ‘-‘, ‘,’, ‘*’, ‘|’, ‘>’, ‘<‘, ‘@’, ‘!’ etc. If such characters appear in column names of values, they must be replaced with another character.

Execute the code in the cell below to replace the ‘/’ characters by ‘or’.

Malaria.columns=[str.replace('/','or') for str in Malaria.columns]

Print the head of the data again to confirm changes have been made.


Execute the code in the cell below to display the data types of each column.


Treat missing values

Missing values are a common problem in a dataset. Failure to deal with missing values before training a machine learning model will lead to biased training at best and in many cases actual failure. The Python scikit-learn package will not process arrays with missing values.

We are going to check which of our columns have missing value(s).

# check for missing values

‘Type of Toilet Facility’ and ‘Cost of Treatment for Fever’ contains missing values. We are going to remove both columns from our dataset.

Malaria.drop('Type of Toilet Facility', axis=1, inplace=True) 
Malaria.drop('Cost of Treatment for Fever', axis=1, inplace=True)

Examine to see if both columns have been removed.


Transform column data type

We have now eliminated all missing values from our dataset. For descriptive analysis purpose. First is to put our table in the form of Pandas DataFrame.

df = pd.DataFrame(Malaria) 

Descriptive Statistics of Nigeria Malaria Data

Here are the results of the descriptives analysis we arrived at after preprocessing of our data from all the steps above.

df['Has Electricity'].value_counts() 
yes    4247 no     3498 Name: Has Electricity, dtype: int64
df['Source of Drinking Water'].value_counts() 
tube well or borehole                                   2795
river/dam/lake/ponds/stream/canal/irrigation channel     829
unprotected well                                         819
protected well                                           786
sachet water                                             786
public tap/standpipe                                     393
unprotected spring                                       349
rainwater                                                308
piped into dwelling                                      238
piped to yard/plot                                       101
protected spring                                          87
piped to neighbor                                         84
tanker truck                                              71
bottled water                                             68
cart with small tank                                      27
other                                                      4
Name: Source of Drinking Water, dtype: int64

df['Wealth Index'].value_counts() 
richer     1844
richest    1816
middle     1676
poorer     1351
poorest    1058
Name: Wealth Index, dtype: int64

df['Has Mosquito Bed Net for Sleeping'].value_counts() 
yes    5432 no     2313 Name: Has Mosquito Bed Net for Sleeping, dtype: int64
df.groupby('Wealth Index')['State'].describe() 
Wealth Index

From the table above, Lagos State has the top number of richest people and Sokoto State has the top number of poorest people

df.groupby('Has Mosquito Bed Net for Sleeping')['State'].describe() 
Has Mosquito Bed Net for Sleeping

From above table Bauchi State has the Highest number of people with Mosquito Bed Net for Sleeping, While Edo State has the least Number

df.groupby('Has Electricity')['State'].describe() 
Has Electricity

From above table Lagos State has the Highest number of people with access to Electricity, While Adamawa State has the least Number