<jupyter_start><jupyter_text>This notebook is for processing Data for Africa Covid-19 Digital Case Study  First We Process the Employment Data(Ratios)<jupyter_code># import pandas 
import pandas as pd
#read the employment data
empdf1 = pd.read_csv('data/API_SL.EMP.TOTL.SP.MA.ZS_DS2_en_csv_v2_1070219.csv', skiprows = 3)
empdf1
#drop Columns
empdf1.drop(['Indicator Name', 'Indicator Code', '1960', '1961', '1962', '1963', '1963', '1964', '1965', '1965', '1966', '1967', '1968', '1969', '1970', '1971', '1972', '1973', '1974', '1975', '1976', '1977', '1978', '1979', '1980', '1981', '1982', '1983', '1984', '1985', '1986', '1987', '1988', '1989', '1990', '1991', '1992', '1993', '1994', '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2019', 'Unnamed: 64'], axis=1, inplace=True)
# show the output
empdf1
# Use the melt function to make the Country Name and Code the Variables
empdf = empdf1.melt(id_vars=['Country Name', 'Country Code'])
empdf
# rename Columns
empdf.rename(columns={'variable':'year', 'value':'emp_rate', 'Country Name':'Country_Name'},inplace=True)
empdf
empdf.Country_Name.unique()
empdf.loc[empdf['Country_Name']=='Congo, Dem. Rep.', 'Country_Name'] = 'Dem Rep Congo'
# pickle dataframe so that it can be used later in other notebooks
empdf.to_pickle("data/empdf_pickle.pkl")<jupyter_output><empty_output><jupyter_text>Now we read the GDP data( GDP per capita)<jupyter_code>import pandas as pd
rawgdp = pd.read_csv('data/API_NY.GDP.PCAP.CD_DS2_en_csv_v2_1068945.csv', skiprows = 3)
rawgdp
#drop Columns
rawgdp.drop(['Indicator Name', 'Indicator Code', '1960', '1961', '1962', '1963', '1963', '1964', '1965', '1965', '1966', '1967', '1968', '1969', '1970', '1971', '1972', '1973', '1974', '1975', '1976', '1977', '1978', '1979', '1980', '1981', '1982', '1983', '1984', '1985', '1986', '1987', '1988', '1989', '1990', '1991', '1992', '1993', '1994', '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2019', 'Unnamed: 64'], axis=1, inplace=True)
rawgdp
gdpdf = rawgdp
gdpdf = pd.melt(gdpdf, id_vars=['Country Name','Country Code'])
gdpdf
gdpdf.rename(columns={'variable':'year', 'value':'GDP', 'Country Name':'Country_Name'},inplace=True)
gdpdf
gdpdf.loc[gdpdf['Country_Name']=='Congo, Dem. Rep.', 'Country_Name'] = 'Dem Rep Congo'
gdpdf.to_pickle("data/gdpdf_pickle.pkl")<jupyter_output><empty_output><jupyter_text>Now we Process the  Africa population data<jupyter_code>import pandas as pd
africapopdf = pd.read_csv('data/Popdata.csv', skiprows=3)
africapopdf
africapopdf.drop(['Type'], axis=1, inplace=True)
africapopdf1 = africapopdf.drop([0, 1, 2])
africapopdf1.columns = ['FIPS', 'CNTRY_NAME', 'Year', 'Pop_Mil']
africapopdf1
africapopdf1.CNTRY_NAME.unique()
africapopdf1.loc[africapopdf1['CNTRY_NAME']=='Congo, Dem. Rep.', 'CNTRY_NAME'] = 'Dem Rep Congo'
africapopdf1.loc[africapopdf1['CNTRY_NAME']=='eSwatini', 'CNTRY_NAME'] = 'Eswatini'
africapopdf1.to_pickle('data/africapopdf1_pickle.pkl')<jupyter_output><empty_output><jupyter_text>Now we will process the data for Confirmed Covid Cases in Africa<jupyter_code>worldcovid_df = pd.read_csv('data/time_series_covid19_deaths_global_narrow.csv')
worldcovid_df
# sort values by Date
worldcovid_df1 = worldcovid_df.sort_values(by="Date")
worldcovid_df1
worldcovid_df2 = worldcovid_df1.drop([0])
worldcovid_df2
#drop Province/State Columns
worldcovid_df2.drop(['Province/State'], axis=1, inplace=True)
worldcovid_df2
worldcovid_df2.columns = ['CNTRY_NAME', 'Lat', 'Long', 'Date', 'Confirmed_Cases']
worldcovid_df2.CNTRY_NAME.unique()
worldcovid_df2.loc[worldcovid_df2['CNTRY_NAME']=='Congo (Kinshasa)', 'CNTRY_NAME'] = 'Dem Rep Congo'
worldcovid_df2.loc[worldcovid_df2['CNTRY_NAME']=='Congo (Brazzaville)', 'CNTRY_NAME'] = 'Rep Congo'
worldcovid_df2.to_pickle('data/worldcovid_df2_pickle.pkl')<jupyter_output><empty_output><jupyter_text>Now we will process Africa Covid Deaths Data<jupyter_code>deaths_df = pd.read_csv('data/Deaths.csv')
deaths_df
deaths_df1 = deaths_df.sort_values(by="Date")
deaths_df1
deaths_df2 = deaths_df1.drop([0])
deaths_df2
#drop Province/State Columns
deaths_df2.drop(['Province/State'], axis=1, inplace=True)
deaths_df2
deaths_df2.columns = ['CNTRY_NAME', 'Lat', 'Long', 'Date', 'Deaths']
deaths_df2.loc[deaths_df2['CNTRY_NAME']=='Congo (Kinshasa)', 'CNTRY_NAME'] = 'Dem Rep Congo'
deaths_df2.loc[deaths_df2['CNTRY_NAME']=='Congo (Brazzaville)', 'CNTRY_NAME'] = 'Rep Congo'
deaths_df2.to_pickle('data/deaths_df2_pickle.pkl')<jupyter_output><empty_output><jupyter_text>Now we Process the Human Development Index Data<jupyter_code>rawhdi= pd.read_csv('data/API_UNDP.HDI.XD_DS11_en_csv_v2_1070220.csv', skiprows=3)
rawhdi
#drop Columns
rawhdi.drop(['Indicator Name', 'Indicator Code', '1960', '1961', '1962', '1963', '1963', '1964', '1965', '1965', '1966', '1967', '1968', '1969', '1970', '1971', '1972', '1973', '1974', '1975', '1976', '1977', '1978', '1979', '1980', '1981', '1982', '1983', '1984', '1985', '1986', '1987', '1988', '1989', '1990', '1991', '1992', '1993', '1994', '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2012', 'Unnamed: 57'], axis=1, inplace=True)
rawhdi
rawhdi1 = rawhdi.drop([0, 44, 46, 49, 56])
rawhdi1
hdi_df = pd.melt(rawhdi1, id_vars=['Country Name', 'Country Code'])
hdi_df
hdi_df.rename(columns={'variable':'year', 'value':'HDI', 'Country Name':'CNTRY_NAME'},inplace=True)
hdi_df
hdi_df.loc[hdi_df['CNTRY_NAME']=='Congo, Dem. Rep.', 'CNTRY_NAME'] = 'Dem Rep Congo'
hdi_df.loc[hdi_df['CNTRY_NAME']=='Congo, Rep.', 'CNTRY_NAME'] = 'Rep Congo'
hdi_df.loc[hdi_df['CNTRY_NAME']=='Swaziland', 'CNTRY_NAME'] = 'Eswatini'
hdi_df.to_pickle('data/hdi_df_pickle.pkl')<jupyter_output><empty_output><jupyter_text>Prepare Confirmed Cases data(Cumulative)<jupyter_code>cumcases_df = pd.read_csv('data/countrycases.csv')
cumcases_df
#drop duplicate columns
cumcases_df.drop(['X', 'Y'], axis=1, inplace=True)
cumcases_df.Country_Region.unique()
cumcases_df.loc[cumcases_df['Country_Region']=='Congo (Kinshasa)', 'Country_Region'] = 'Dem Rep Congo'
cumcases_df.loc[cumcases_df['Country_Region']=='Congo (Brazzaville)', 'Country_Region'] = 'Rep Congo'
cumcases_df.to_pickle('data/cumcases_df_pickle.pkl')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1961094417207022, 'fraction_numerical': 0.11481891507195952, 'mean_word_length': 8.654961832061069, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '330727', 'license': 'Apache-2.0', 'n_tokens_mistral': 3081, 'n_tokens_neox': 2498, 'n_words': 504, 'path': 'NB03-AfricaCovid19-DataProcessing.ipynb', 'repo_name': 'PHI-Case-Studies/2019-COVID19-Africa-Basic', 'size': '6323'}