<jupyter_start><jupyter_text>TASK-1  Import Libraries<jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Load Data<jupyter_code>df1 = pd.read_csv("https://raw.githubusercontent.com/dphi-official/Datasets/master/world-happiness-report-2021.csv")
df1.head(5) #Displaying first five rows of world-happiness-report-2021
df1.tail(10) #Displaying last ten rows of world-happiness-report-2021
df1.info() #Concise Summary of the data
df1.info(verbose = False)<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 149 entries, 0 to 148
Columns: 20 entries, Country name to Dystopia + residual
dtypes: float64(18), object(2)
memory usage: 23.4+ KB<jupyter_text>OBSERVATIONS<jupyter_code>#We can observe that there are no null values/missing data
#There are 149 entries with two data types- float64(18) & object(2)<jupyter_output><empty_output><jupyter_text>Descriptive Statistics<jupyter_code>df1.describe(include='all')<jupyter_output><empty_output><jupyter_text>Checking for Missing values<jupyter_code>df1.isnull()
df1.isnull().sum()
#No missing values<jupyter_output><empty_output><jupyter_text>Number of unique countries in western europe<jupyter_code>WesternEurope = df1[df1['Regional indicator'] == 'Western Europe']
len(WesternEurope)
# 21 unique countries in Western Europe
WesternEurope['Country name'] # All western countries in Europe<jupyter_output><empty_output><jupyter_text>Displaying happiness score of India<jupyter_code>India = df1[df1['Country name'] == 'India']
India[['Country name','Ladder score']]
#World Happiness score of India as per World Happiness Report 2021 is 3.819<jupyter_output><empty_output><jupyter_text>TASK-2  Top 5 East Asian countries based on Generosity<jupyter_code>EastAsian = df1[df1['Regional indicator'] == 'East Asia']
Generosity=EastAsian.sort_values("Explained by: Generosity",ascending=False).head(5)
Generosity[['Country name','Explained by: Generosity']]<jupyter_output><empty_output><jupyter_text>Line Plot of Ladder Score VS top 5 east asian countries based on Generosity<jupyter_code>Generosity[['Country name','Ladder score']]
Generosity.plot( x='Country name', y='Ladder score',marker='o')
plt.xticks(rotation = 45)<jupyter_output><empty_output><jupyter_text>South East Asia Countries<jupyter_code>SouthEastAsian = df1[df1['Regional indicator'] == 'Southeast Asia']
SouthEastAsian
GenSouth=SouthEastAsian.sort_values("Explained by: Generosity",ascending=False).head(5)
GenSouth[['Country name','Explained by: Generosity']]<jupyter_output><empty_output><jupyter_text>Line Plot of Ladder Score VS top 5 South East Asian countries based on 'Generosity'<jupyter_code>GenSouth[['Country name','Ladder score']]
GenSouth.plot( x='Country name', y='Ladder score',marker='o')
plt.xticks(rotation = 45)<jupyter_output><empty_output><jupyter_text>Creating a dataframe object : df_2021 with the following countries: 'China', 'Nepal', 'Bangladesh', 'Pakistan', 'Myanmar', 'India', 'Afghanistan'.<jupyter_code>df_2021 = df1[df1['Country name'].isin(['China', 'Nepal', 'Bangladesh', 'Pakistan', 'Myanmar', 'India', 'Afghanistan'])]
df_2021<jupyter_output><empty_output><jupyter_text>Scatter plot to showing the relation between these countries vs their 'Logged GDP per capita'<jupyter_code>df_2021[['Country name','Logged GDP per capita']]
df_2021.plot.scatter( x='Country name', y='Logged GDP per capita',marker='o')
plt.xticks(rotation=45)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12686139747995417, 'fraction_numerical': 0.028923253150057275, 'mean_word_length': 9.45808383233533, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 53, 'https://': 1, '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': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '602584', 'license': 'MIT', 'n_tokens_mistral': 1289, 'n_tokens_neox': 1171, 'n_words': 263, 'path': 'Data visualization with Matplotlib/Dphi Data Visualisation Final Assignment (1).ipynb', 'repo_name': 'Adwaita10/DPhi_Bootcamp', 'size': '3492'}