<jupyter_start><jupyter_text>Matplolib Task<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
%config InlineBackend.figure_format = 'retina'

plt.style.use('ggplot')
df = pd.read_csv("data/pandas_tasks.csv")<jupyter_output><empty_output><jupyter_text>Instruction * Using the loaded dataset, make a boxplot, barplot, histogram, and a scatter plot. * Ensure to provide appropriate labels, and titles where necessary. * In each plot, ensure to use all parameters used in the Matplolib tutorial.* Optionally, add additional parameters for each plot for some extra points.* For each of the plot, choose appropriate columns in the dataset. The explanation for each of the variables has been provided in a word document called `Variable_Codebook.docx`.<jupyter_code>df.head()<jupyter_output><empty_output><jupyter_text>${\textbf{Plotting Scatter Plot}}$<jupyter_code>fig, ax = plt.subplots(figsize=(12, 7))
plt.scatter(df['Latitude'], df['Longitude'], alpha=0.5)
plt.xlabel('Latitude', fontsize=18, fontweight='bold')
plt.ylabel('Longitude', fontsize=18, fontweight='bold')
plt.title('Latitude Vs Longitude', size=25)
plt.show()<jupyter_output><empty_output><jupyter_text>${\textbf{Plotting Bar Chart}}$<jupyter_code>df['savings'].value_counts().plot.bar(figsize=(12, 7), color=['#671099', '#889921'])
plt.title('Distribution of Savings in the Data', size=22, fontweight='bold')
plt.ylabel('Frequency', fontsize=18)
plt.show()
def plot_bar(data, col):
    """
    plot categorical columns to show its distribution in the data
    """
    data[col].value_counts().plot.bar(figsize=(12, 7), color=['#671099', '#889921'])
    plt.title(f'{col} Distribution', size=22, color='#889222')
    plt.ylabel('Frequency', fontsize=18)
    plt.xticks(fontsize=14, rotation=360)
    plt.yticks(fontsize=15)
    plt.legend(loc='best', fontsize=15)
    plt.show()
category_columns = [ 'mobile_money', 'savings', 'borrowing', 'insurance']
for cat_col in category_columns:
    plot_bar(df, cat_col)
df['Q3'] = df['Q3'].replace({1:'Married', 2:'Divorced', 3:'Widowed', 4:'Single'})
df['Q3'].value_counts().plot.bar(figsize=(12, 7), color=['#671099', '#889921', 'gray', 'green'])
plt.title('Marital Status Distribution', size=22,  fontfamily='sans-serif')
plt.ylabel('Frequency', fontsize=18)
plt.xticks(fontsize=14, rotation=45)
plt.yticks(fontsize=14)

plt.show()
l_edu = ['Primary', 'No formal education', 'Some Primary', 'University', 'Secondary', 'Dont Know',
        'Techmical Trainig', 'Nill']
df['Q4'] = df['Q4'].replace({3: l_edu[0], 1:l_edu[1], 2:l_edu[2], 6:l_edu[3], 5:l_edu[4], 7:l_edu[5],
                            4:l_edu[6], 8:l_edu[-1]})
df['Q4'].value_counts().plot.bar(figsize=(12, 7), color=['#671099', '#889921'])
plt.title('Level of Education', size=22, fontfamily='arial')
plt.ylabel('Frequency', fontsize=18)
plt.xticks(fontsize=14, rotation=70)
plt.yticks(fontsize=14)

plt.show()<jupyter_output><empty_output><jupyter_text>${\textbf{Plotting Histogram}}$<jupyter_code>plt.figure(figsize=(12, 7))
plt.hist(df['Q1'], bins=40, color='r', histtype='stepfilled')
plt.title('Histogram Chart of Age', size=22)
plt.xlabel('Age Values', fontsize=16)
plt.ylabel('Frequency', fontsize=16)
plt.show()<jupyter_output><empty_output><jupyter_text>${\textbf{Plotting Box Plot}}$<jupyter_code>plt.figure(figsize=(12, 7))
plt.boxplot(df['Latitude'], vert=True, meanline=True, showcaps=True, labels=['Latitude'])
plt.title('A Box plot showing the spread of Latitude', size=22)
plt.show()
plt.figure(figsize=(12, 7))
plt.boxplot(df['Longitude'], vert=True, meanline=True, showcaps=True, labels=['Longitude'],
            medianprops={'linewidth': 2, 'color': 'green'},
           meanprops={'linewidth': 2, 'color': 'red'})
plt.title('A Box plot showing the spread of Longitude', size=22)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17919375812743824, 'fraction_numerical': 0.042652795838751624, 'mean_word_length': 6.995841995841996, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '489793', 'license': 'Apache-2.0', 'n_tokens_mistral': 1506, 'n_tokens_neox': 1364, 'n_words': 286, 'path': 'Day 4/alaroabubakarolayemi@yahoo.com(Matplotlib Task).ipynb', 'repo_name': 'Abuton/10-Academy-5days-Challenge', 'size': '3845'}