Happiness/hivemind1.ipynb

4176 lines
148 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "hivemind1.ipynb",
"provenance": [],
"collapsed_sections": [],
"toc_visible": true,
"authorship_tag": "ABX9TyPDIxFOaQ6ugsOYXbj0e6It",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"f24a2c9e820b4249ab63654b9ef56604": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HBoxModel",
"state": {
"_view_name": "HBoxView",
"_dom_classes": [],
"_model_name": "HBoxModel",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.5.0",
"box_style": "",
"layout": "IPY_MODEL_e4dc73cf71714fd38dd09fd06a8608c7",
"_model_module": "@jupyter-widgets/controls",
"children": [
"IPY_MODEL_652720149f1843cd964a3fae5a32b6d7",
"IPY_MODEL_a5b643a5d4db43769c04ded49d2ba09e"
]
}
},
"e4dc73cf71714fd38dd09fd06a8608c7": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"652720149f1843cd964a3fae5a32b6d7": {
"model_module": "@jupyter-widgets/controls",
"model_name": "FloatProgressModel",
"state": {
"_view_name": "ProgressView",
"style": "IPY_MODEL_2859a8220b6340fcba1862b35fbe5b91",
"_dom_classes": [],
"description": "UCF101TrainTestSplits-RecognitionTask.zip: 100%",
"_model_name": "FloatProgressModel",
"bar_style": "success",
"max": 113943,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 113943,
"_view_count": null,
"_view_module_version": "1.5.0",
"orientation": "horizontal",
"min": 0,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_cfa563330e4b45cd9a4197bdf9ec6757"
}
},
"a5b643a5d4db43769c04ded49d2ba09e": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"state": {
"_view_name": "HTMLView",
"style": "IPY_MODEL_838f5f7533314ade8fa3859ef7f46bf1",
"_dom_classes": [],
"description": "",
"_model_name": "HTMLModel",
"placeholder": "",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": " 111k/111k [00:00<00:00, 1.49MB/s]",
"_view_count": null,
"_view_module_version": "1.5.0",
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_6a30b268827f42e78da55a27979ddf47"
}
},
"2859a8220b6340fcba1862b35fbe5b91": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "ProgressStyleModel",
"description_width": "initial",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"bar_color": null,
"_model_module": "@jupyter-widgets/controls"
}
},
"cfa563330e4b45cd9a4197bdf9ec6757": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"838f5f7533314ade8fa3859ef7f46bf1": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "DescriptionStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"6a30b268827f42e78da55a27979ddf47": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"d15b4d02e1d84ce9b218dde279f11c59": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HBoxModel",
"state": {
"_view_name": "HBoxView",
"_dom_classes": [],
"_model_name": "HBoxModel",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.5.0",
"box_style": "",
"layout": "IPY_MODEL_446c92b5b92845249477c60af3f63faf",
"_model_module": "@jupyter-widgets/controls",
"children": [
"IPY_MODEL_d63d7a10beab42179bcd6b4f5a433a49",
"IPY_MODEL_771d95358ad64e9c8742e416e61261da"
]
}
},
"446c92b5b92845249477c60af3f63faf": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"d63d7a10beab42179bcd6b4f5a433a49": {
"model_module": "@jupyter-widgets/controls",
"model_name": "FloatProgressModel",
"state": {
"_view_name": "ProgressView",
"style": "IPY_MODEL_767d69f1b35e4df8bb4e718772c02b20",
"_dom_classes": [],
"description": "UCF101.rar: 100%",
"_model_name": "FloatProgressModel",
"bar_style": "success",
"max": 6932971618,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 6932971618,
"_view_count": null,
"_view_module_version": "1.5.0",
"orientation": "horizontal",
"min": 0,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_8741b1c90f514abc950d3cdf4d63b5bf"
}
},
"771d95358ad64e9c8742e416e61261da": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"state": {
"_view_name": "HTMLView",
"style": "IPY_MODEL_52f2278bb6f04526a08a75db50680708",
"_dom_classes": [],
"description": "",
"_model_name": "HTMLModel",
"placeholder": "",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": " 6.46G/6.46G [01:59<00:00, 57.8MB/s]",
"_view_count": null,
"_view_module_version": "1.5.0",
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_15696888463a4d668d7ff7e4f5c93ee3"
}
},
"767d69f1b35e4df8bb4e718772c02b20": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "ProgressStyleModel",
"description_width": "initial",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"bar_color": null,
"_model_module": "@jupyter-widgets/controls"
}
},
"8741b1c90f514abc950d3cdf4d63b5bf": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"52f2278bb6f04526a08a75db50680708": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "DescriptionStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"15696888463a4d668d7ff7e4f5c93ee3": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
}
}
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/Priyatham-sai-chand/Happiness/blob/master/hivemind1.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "tQsU9aGhmLPo",
"colab_type": "text"
},
"source": [
"# **HiveMind Level : 1**\n",
"\n",
"# Task 1\n",
"\n",
" **The world happiness\n",
"index dataset for 2015, 2016 and 2017**\n",
"\n",
"Datasets source : [https://www.kaggle.com/unsdsn/world-happiness](https://www.kaggle.com/unsdsn/world-happiness)\n",
"\n",
"Raw csv files source : [https://github.com/Priyatham-sai-chand/Happiness/tree/master](https://github.com/Priyatham-sai-chand/Happiness/tree/master)"
]
},
{
"cell_type": "code",
"metadata": {
"id": "VP1EHLddnnsE",
"colab_type": "code",
"outputId": "50c9d266-0e96-439d-d9d4-26140bf49299",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
}
},
"source": [
"#Packages\n",
"import pandas as pd\n",
"from pprint import pprint\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib"
],
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"text": [
"Using matplotlib backend: agg\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "yUHCdQe2F8ja",
"colab_type": "code",
"colab": {}
},
"source": [
"\n",
"#URLs contaning the raw csv files\n",
"url_2015 = \"https://raw.githubusercontent.com/Priyatham-sai-chand/Happiness/master/2015.csv\"\n",
"url_2016 = \"https://raw.githubusercontent.com/Priyatham-sai-chand/Happiness/master/2016.csv\"\n",
"url_2017 = \"https://raw.githubusercontent.com/Priyatham-sai-chand/Happiness/master/2017.csv\"\n",
"\n",
"#intialising dataframes with the URLs Content\n",
"df_2015 = pd.read_csv(url_2015)\n",
"df_2016 = pd.read_csv(url_2016)\n",
"df_2017 = pd.read_csv(url_2017)\n"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "S0yp0ObZCAKa",
"colab_type": "text"
},
"source": [
"# Question 1 \n",
"\n",
"**Countries with a happiness score of less than 5.0**\n"
]
},
{
"cell_type": "code",
"metadata": {
"id": "QQPc4ZSniHLc",
"colab_type": "code",
"colab": {}
},
"source": [
"def happiness_less_than_score(df,score):\n",
" \"\"\"Gathers the country names with happiness score less than specified.\"\"\"\n",
" if df.equals(df_2015):\n",
" return df_2015['Country'][df_2015['Happiness Score'] < score]\n",
" elif df.equals(df_2016):\n",
" return df_2016['Country'][df_2016['Happiness Score'] < score]\n",
" elif df.equals(df_2017):\n",
" return df_2017['Country'][df_2017['Happiness.Score'] < score]\n",
" \n",
"\n"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "VMwEAVyyCijU",
"colab_type": "text"
},
"source": [
"**Answer**"
]
},
{
"cell_type": "code",
"metadata": {
"id": "WoMb20oCvxY4",
"colab_type": "code",
"outputId": "15265a3f-127a-4a30-855c-b16d25d7b1ab",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 173
}
},
"source": [
"### Run this cell ###\n",
"\n",
"result = happiness_less_than_score(df_2015,5.0)\n",
"print(\"In Year 2015: \")\n",
"print(result.tolist()) #pprint(result.tolist())\n",
"print()\n",
"result = happiness_less_than_score(df_2016,5.0)\n",
"print(\"In Year 2016: \")\n",
"print(result.tolist()) #pprint(result.tolist())\n",
"print()\n",
"result = happiness_less_than_score(df_2017,5.0)\n",
"print(\"In Year 2017: \")\n",
"print(result.tolist()) #pprint(result.tolist())"
],
"execution_count": 4,
"outputs": [
{
"output_type": "stream",
"text": [
"In Year 2015: \n",
"['Mozambique', 'Albania', 'Bosnia and Herzegovina', 'Lesotho', 'Dominican Republic', 'Laos', 'Mongolia', 'Swaziland', 'Greece', 'Lebanon', 'Hungary', 'Honduras', 'Tajikistan', 'Tunisia', 'Palestinian Territories', 'Bangladesh', 'Iran', 'Ukraine', 'Iraq', 'South Africa', 'Ghana', 'Zimbabwe', 'Liberia', 'India', 'Sudan', 'Haiti', 'Congo (Kinshasa)', 'Nepal', 'Ethiopia', 'Sierra Leone', 'Mauritania', 'Kenya', 'Djibouti', 'Armenia', 'Botswana', 'Myanmar', 'Georgia', 'Malawi', 'Sri Lanka', 'Cameroon', 'Bulgaria', 'Egypt', 'Yemen', 'Angola', 'Mali', 'Congo (Brazzaville)', 'Comoros', 'Uganda', 'Senegal', 'Gabon', 'Niger', 'Cambodia', 'Tanzania', 'Madagascar', 'Central African Republic', 'Chad', 'Guinea', 'Ivory Coast', 'Burkina Faso', 'Afghanistan', 'Rwanda', 'Benin', 'Syria', 'Burundi', 'Togo']\n",
"\n",
"In Year 2016: \n",
"['Tajikistan', 'Mongolia', 'Laos', 'Nigeria', 'Honduras', 'Iran', 'Zambia', 'Nepal', 'Palestinian Territories', 'Albania', 'Bangladesh', 'Sierra Leone', 'Iraq', 'Namibia', 'Cameroon', 'Ethiopia', 'South Africa', 'Sri Lanka', 'India', 'Myanmar', 'Egypt', 'Armenia', 'Kenya', 'Ukraine', 'Ghana', 'Congo (Kinshasa)', 'Georgia', 'Congo (Brazzaville)', 'Senegal', 'Bulgaria', 'Mauritania', 'Zimbabwe', 'Malawi', 'Sudan', 'Gabon', 'Mali', 'Haiti', 'Botswana', 'Comoros', 'Ivory Coast', 'Cambodia', 'Angola', 'Niger', 'South Sudan', 'Chad', 'Burkina Faso', 'Uganda', 'Yemen', 'Madagascar', 'Tanzania', 'Liberia', 'Guinea', 'Rwanda', 'Benin', 'Afghanistan', 'Togo', 'Syria', 'Burundi']\n",
"\n",
"In Year 2017: \n",
"['Nepal', 'Mongolia', 'South Africa', 'Tunisia', 'Palestinian Territories', 'Egypt', 'Bulgaria', 'Sierra Leone', 'Cameroon', 'Iran', 'Albania', 'Bangladesh', 'Namibia', 'Kenya', 'Mozambique', 'Myanmar', 'Senegal', 'Zambia', 'Iraq', 'Gabon', 'Ethiopia', 'Sri Lanka', 'Armenia', 'India', 'Mauritania', 'Congo (Brazzaville)', 'Georgia', 'Congo (Kinshasa)', 'Mali', 'Ivory Coast', 'Cambodia', 'Sudan', 'Ghana', 'Ukraine', 'Uganda', 'Burkina Faso', 'Niger', 'Malawi', 'Chad', 'Zimbabwe', 'Lesotho', 'Angola', 'Afghanistan', 'Botswana', 'Benin', 'Madagascar', 'Haiti', 'Yemen', 'South Sudan', 'Liberia', 'Guinea', 'Togo', 'Rwanda', 'Syria', 'Tanzania', 'Burundi', 'Central African Republic']\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "G81dLVMKHxP4",
"colab_type": "text"
},
"source": [
"# Question 2\n",
"\n",
" **Which is the unhappiest country in Sub-Saharan Africa?**"
]
},
{
"cell_type": "code",
"metadata": {
"id": "PuTbRNV1iKCn",
"colab_type": "code",
"colab": {}
},
"source": [
"def unhappiest_in_region(df,region):\n",
" \"\"\" Finds the least happiness score in the specified region.\"\"\"\n",
" if df.equals(df_2015):\n",
" df_temp = df_2015[df_2015['Region'] == region]\n",
" return df_temp[df_temp['Happiness Score'] == df_temp['Happiness Score'].min()]\n",
" elif df.equals(df_2016):\n",
" df_temp = df_2016[df_2016['Region'] == region]\n",
" return df_temp[df_temp['Happiness Score'] == df_temp['Happiness Score'].min()]\n",
" elif df.equals(df_2017):\n",
" # Since 2017 report doesn't contain regions they are explictly taken from the 2015 year's countries under that region.\n",
"\n",
" df_region_country = df_2015['Country'][df_2015['Region'] == region].to_frame()\n",
" df_temp = df_2017[df_2017['Country'].isin(df_region_country['Country'])]\n",
" return df_temp[df_temp['Happiness.Score'] == df_temp['Happiness.Score'].min()]\n",
"\n",
"\n"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "KnBWfhCRnLX-",
"colab_type": "text"
},
"source": [
"**Answer:**"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "sAJozClfuzOg",
"colab_type": "text"
},
"source": [
""
]
},
{
"cell_type": "code",
"metadata": {
"id": "Nhg53virJyIg",
"colab_type": "code",
"outputId": "50a6e85c-7c9e-431a-b062-07a457a12390",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 153
}
},
"source": [
"### Run this cell ###\n",
"\n",
"result = unhappiest_in_region(df_2015,\"Sub-Saharan Africa\")\n",
"print(\"In Year 2015: \")\n",
"print(result['Country'].tolist()) \n",
"print()\n",
"result = unhappiest_in_region(df_2016,\"Sub-Saharan Africa\")\n",
"print(\"In Year 2016: \")\n",
"print(result['Country'].tolist()) \n",
"print()\n",
"result = unhappiest_in_region(df_2017,\"Sub-Saharan Africa\")\n",
"print(\"In Year 2017: \")\n",
"print(result['Country'].tolist()) "
],
"execution_count": 6,
"outputs": [
{
"output_type": "stream",
"text": [
"In Year 2015: \n",
"['Togo']\n",
"\n",
"In Year 2016: \n",
"['Burundi']\n",
"\n",
"In Year 2017: \n",
"['Central African Republic']\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "4_g7pwTToMFy",
"colab_type": "text"
},
"source": [
"# Question 3\n",
"\n",
"3. Compare the Unhappiest and happiest countries in each region"
]
},
{
"cell_type": "code",
"metadata": {
"id": "msP1YFy9oRtA",
"colab_type": "code",
"colab": {}
},
"source": [
"def happiest_in_region(df,region):\n",
" \"\"\" Finds the most happiness score in the specified region.\"\"\"\n",
" if df.equals(df_2015):\n",
" df_temp = df_2015[df_2015['Region'] == region]\n",
" return df_temp[df_temp['Happiness Score'] == df_temp['Happiness Score'].max()]\n",
" elif df.equals(df_2016):\n",
" df_temp = df_2016[df_2016['Region'] == region]\n",
" return df_temp[df_temp['Happiness Score'] == df_temp['Happiness Score'].max()]\n",
" elif df.equals(df_2017):\n",
" # Since 2017 report doesn't contain regions they are explictly taken from the 2015 year's countries under that region.\n",
"\n",
" df_region_country = df_2015['Country'][df_2015['Region'] == region].to_frame()\n",
" df_temp = df_2017[df_2017['Country'].isin(df_region_country['Country'])]\n",
" return df_temp[df_temp['Happiness.Score'] == df_temp['Happiness.Score'].max()]"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "75LzYGVl_mNB",
"colab_type": "text"
},
"source": [
"**Answer**"
]
},
{
"cell_type": "code",
"metadata": {
"id": "APYCHnWqoSN4",
"colab_type": "code",
"outputId": "6ebc9569-259d-4b41-83eb-c16cfd936ccc",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
}
},
"source": [
"\n",
"## Run this cell ##\n",
"\n",
"print('In the Year 2015 ')\n",
"for region in df_2015['Region'].unique():\n",
" print()\n",
" print(region )\n",
" print()\n",
" result = unhappiest_in_region(df_2015,region) #from question 2\n",
" result1 = happiest_in_region(df_2015,region)\n",
" display(result1.append(result))\n",
"\n",
"print('In the Year 2016 ')\n",
"for region in df_2016['Region'].unique():\n",
" print\n",
" print(region )\n",
" print()\n",
" result = unhappiest_in_region(df_2016,region) #from question 2\n",
" result1 = happiest_in_region(df_2016,region)\n",
" display(result1.append(result))\n",
"\n",
"print('In the Year 2017 ')\n",
"for region in df_2015['Region'].unique():\n",
" print()\n",
" print(region )\n",
" print()\n",
" result = unhappiest_in_region(df_2017,region) #from question 2\n",
" result1 = happiest_in_region(df_2017,region)\n",
" display(result1.append(result))\n"
],
"execution_count": 8,
"outputs": [
{
"output_type": "stream",
"text": [
"In the Year 2015 \n",
"\n",
"Western Europe\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Standard Error</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Switzerland</td>\n",
" <td>Western Europe</td>\n",
" <td>1</td>\n",
" <td>7.587</td>\n",
" <td>0.03411</td>\n",
" <td>1.39651</td>\n",
" <td>1.34951</td>\n",
" <td>0.94143</td>\n",
" <td>0.66557</td>\n",
" <td>0.41978</td>\n",
" <td>0.29678</td>\n",
" <td>2.51738</td>\n",
" </tr>\n",
" <tr>\n",
" <th>101</th>\n",
" <td>Greece</td>\n",
" <td>Western Europe</td>\n",
" <td>102</td>\n",
" <td>4.857</td>\n",
" <td>0.05062</td>\n",
" <td>1.15406</td>\n",
" <td>0.92933</td>\n",
" <td>0.88213</td>\n",
" <td>0.07699</td>\n",
" <td>0.01397</td>\n",
" <td>0.00000</td>\n",
" <td>1.80101</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"0 Switzerland Western Europe ... 0.29678 2.51738\n",
"101 Greece Western Europe ... 0.00000 1.80101\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n",
"North America\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Standard Error</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Canada</td>\n",
" <td>North America</td>\n",
" <td>5</td>\n",
" <td>7.427</td>\n",
" <td>0.03553</td>\n",
" <td>1.32629</td>\n",
" <td>1.32261</td>\n",
" <td>0.90563</td>\n",
" <td>0.63297</td>\n",
" <td>0.32957</td>\n",
" <td>0.45811</td>\n",
" <td>2.45176</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>United States</td>\n",
" <td>North America</td>\n",
" <td>15</td>\n",
" <td>7.119</td>\n",
" <td>0.03839</td>\n",
" <td>1.39451</td>\n",
" <td>1.24711</td>\n",
" <td>0.86179</td>\n",
" <td>0.54604</td>\n",
" <td>0.15890</td>\n",
" <td>0.40105</td>\n",
" <td>2.51011</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"4 Canada North America ... 0.45811 2.45176\n",
"14 United States North America ... 0.40105 2.51011\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n",
"Australia and New Zealand\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Standard Error</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>New Zealand</td>\n",
" <td>Australia and New Zealand</td>\n",
" <td>9</td>\n",
" <td>7.286</td>\n",
" <td>0.03371</td>\n",
" <td>1.25018</td>\n",
" <td>1.31967</td>\n",
" <td>0.90837</td>\n",
" <td>0.63938</td>\n",
" <td>0.42922</td>\n",
" <td>0.47501</td>\n",
" <td>2.26425</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>Australia</td>\n",
" <td>Australia and New Zealand</td>\n",
" <td>10</td>\n",
" <td>7.284</td>\n",
" <td>0.04083</td>\n",
" <td>1.33358</td>\n",
" <td>1.30923</td>\n",
" <td>0.93156</td>\n",
" <td>0.65124</td>\n",
" <td>0.35637</td>\n",
" <td>0.43562</td>\n",
" <td>2.26646</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"8 New Zealand Australia and New Zealand ... 0.47501 2.26425\n",
"9 Australia Australia and New Zealand ... 0.43562 2.26646\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n",
"Middle East and Northern Africa\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Standard Error</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>Israel</td>\n",
" <td>Middle East and Northern Africa</td>\n",
" <td>11</td>\n",
" <td>7.278</td>\n",
" <td>0.03470</td>\n",
" <td>1.22857</td>\n",
" <td>1.22393</td>\n",
" <td>0.91387</td>\n",
" <td>0.41319</td>\n",
" <td>0.07785</td>\n",
" <td>0.33172</td>\n",
" <td>3.08854</td>\n",
" </tr>\n",
" <tr>\n",
" <th>155</th>\n",
" <td>Syria</td>\n",
" <td>Middle East and Northern Africa</td>\n",
" <td>156</td>\n",
" <td>3.006</td>\n",
" <td>0.05015</td>\n",
" <td>0.66320</td>\n",
" <td>0.47489</td>\n",
" <td>0.72193</td>\n",
" <td>0.15684</td>\n",
" <td>0.18906</td>\n",
" <td>0.47179</td>\n",
" <td>0.32858</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"10 Israel Middle East and Northern Africa ... 0.33172 3.08854\n",
"155 Syria Middle East and Northern Africa ... 0.47179 0.32858\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n",
"Latin America and Caribbean\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Standard Error</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>Costa Rica</td>\n",
" <td>Latin America and Caribbean</td>\n",
" <td>12</td>\n",
" <td>7.226</td>\n",
" <td>0.04454</td>\n",
" <td>0.95578</td>\n",
" <td>1.23788</td>\n",
" <td>0.86027</td>\n",
" <td>0.63376</td>\n",
" <td>0.10583</td>\n",
" <td>0.25497</td>\n",
" <td>3.17728</td>\n",
" </tr>\n",
" <tr>\n",
" <th>118</th>\n",
" <td>Haiti</td>\n",
" <td>Latin America and Caribbean</td>\n",
" <td>119</td>\n",
" <td>4.518</td>\n",
" <td>0.07331</td>\n",
" <td>0.26673</td>\n",
" <td>0.74302</td>\n",
" <td>0.38847</td>\n",
" <td>0.24425</td>\n",
" <td>0.17175</td>\n",
" <td>0.46187</td>\n",
" <td>2.24173</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"11 Costa Rica Latin America and Caribbean ... 0.25497 3.17728\n",
"118 Haiti Latin America and Caribbean ... 0.46187 2.24173\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n",
"Southeastern Asia\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Standard Error</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>Singapore</td>\n",
" <td>Southeastern Asia</td>\n",
" <td>24</td>\n",
" <td>6.798</td>\n",
" <td>0.03780</td>\n",
" <td>1.52186</td>\n",
" <td>1.02000</td>\n",
" <td>1.02525</td>\n",
" <td>0.54252</td>\n",
" <td>0.49210</td>\n",
" <td>0.31105</td>\n",
" <td>1.88501</td>\n",
" </tr>\n",
" <tr>\n",
" <th>144</th>\n",
" <td>Cambodia</td>\n",
" <td>Southeastern Asia</td>\n",
" <td>145</td>\n",
" <td>3.819</td>\n",
" <td>0.05069</td>\n",
" <td>0.46038</td>\n",
" <td>0.62736</td>\n",
" <td>0.61114</td>\n",
" <td>0.66246</td>\n",
" <td>0.07247</td>\n",
" <td>0.40359</td>\n",
" <td>0.98195</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"23 Singapore Southeastern Asia ... 0.31105 1.88501\n",
"144 Cambodia Southeastern Asia ... 0.40359 0.98195\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n",
"Central and Eastern Europe\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Standard Error</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>30</th>\n",
" <td>Czech Republic</td>\n",
" <td>Central and Eastern Europe</td>\n",
" <td>31</td>\n",
" <td>6.505</td>\n",
" <td>0.04168</td>\n",
" <td>1.17898</td>\n",
" <td>1.20643</td>\n",
" <td>0.84483</td>\n",
" <td>0.46364</td>\n",
" <td>0.02652</td>\n",
" <td>0.10686</td>\n",
" <td>2.67782</td>\n",
" </tr>\n",
" <tr>\n",
" <th>133</th>\n",
" <td>Bulgaria</td>\n",
" <td>Central and Eastern Europe</td>\n",
" <td>134</td>\n",
" <td>4.218</td>\n",
" <td>0.04828</td>\n",
" <td>1.01216</td>\n",
" <td>1.10614</td>\n",
" <td>0.76649</td>\n",
" <td>0.30587</td>\n",
" <td>0.00872</td>\n",
" <td>0.11921</td>\n",
" <td>0.89991</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"30 Czech Republic Central and Eastern Europe ... 0.10686 2.67782\n",
"133 Bulgaria Central and Eastern Europe ... 0.11921 0.89991\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n",
"Eastern Asia\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Standard Error</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>37</th>\n",
" <td>Taiwan</td>\n",
" <td>Eastern Asia</td>\n",
" <td>38</td>\n",
" <td>6.298</td>\n",
" <td>0.03868</td>\n",
" <td>1.29098</td>\n",
" <td>1.07617</td>\n",
" <td>0.87530</td>\n",
" <td>0.39740</td>\n",
" <td>0.08129</td>\n",
" <td>0.25376</td>\n",
" <td>2.32323</td>\n",
" </tr>\n",
" <tr>\n",
" <th>99</th>\n",
" <td>Mongolia</td>\n",
" <td>Eastern Asia</td>\n",
" <td>100</td>\n",
" <td>4.874</td>\n",
" <td>0.03313</td>\n",
" <td>0.82819</td>\n",
" <td>1.30060</td>\n",
" <td>0.60268</td>\n",
" <td>0.43626</td>\n",
" <td>0.02666</td>\n",
" <td>0.33230</td>\n",
" <td>1.34759</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"37 Taiwan Eastern Asia ... 0.25376 2.32323\n",
"99 Mongolia Eastern Asia ... 0.33230 1.34759\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n",
"Sub-Saharan Africa\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Standard Error</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>70</th>\n",
" <td>Mauritius</td>\n",
" <td>Sub-Saharan Africa</td>\n",
" <td>71</td>\n",
" <td>5.477</td>\n",
" <td>0.07197</td>\n",
" <td>1.00761</td>\n",
" <td>0.98521</td>\n",
" <td>0.70950</td>\n",
" <td>0.56066</td>\n",
" <td>0.07521</td>\n",
" <td>0.37744</td>\n",
" <td>1.76145</td>\n",
" </tr>\n",
" <tr>\n",
" <th>157</th>\n",
" <td>Togo</td>\n",
" <td>Sub-Saharan Africa</td>\n",
" <td>158</td>\n",
" <td>2.839</td>\n",
" <td>0.06727</td>\n",
" <td>0.20868</td>\n",
" <td>0.13995</td>\n",
" <td>0.28443</td>\n",
" <td>0.36453</td>\n",
" <td>0.10731</td>\n",
" <td>0.16681</td>\n",
" <td>1.56726</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"70 Mauritius Sub-Saharan Africa ... 0.37744 1.76145\n",
"157 Togo Sub-Saharan Africa ... 0.16681 1.56726\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n",
"Southern Asia\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Standard Error</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>78</th>\n",
" <td>Bhutan</td>\n",
" <td>Southern Asia</td>\n",
" <td>79</td>\n",
" <td>5.253</td>\n",
" <td>0.03225</td>\n",
" <td>0.77042</td>\n",
" <td>1.10395</td>\n",
" <td>0.57407</td>\n",
" <td>0.53206</td>\n",
" <td>0.15445</td>\n",
" <td>0.47998</td>\n",
" <td>1.63794</td>\n",
" </tr>\n",
" <tr>\n",
" <th>152</th>\n",
" <td>Afghanistan</td>\n",
" <td>Southern Asia</td>\n",
" <td>153</td>\n",
" <td>3.575</td>\n",
" <td>0.03084</td>\n",
" <td>0.31982</td>\n",
" <td>0.30285</td>\n",
" <td>0.30335</td>\n",
" <td>0.23414</td>\n",
" <td>0.09719</td>\n",
" <td>0.36510</td>\n",
" <td>1.95210</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"78 Bhutan Southern Asia ... 0.47998 1.63794\n",
"152 Afghanistan Southern Asia ... 0.36510 1.95210\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"In the Year 2016 \n",
"Western Europe\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Lower Confidence Interval</th>\n",
" <th>Upper Confidence Interval</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Denmark</td>\n",
" <td>Western Europe</td>\n",
" <td>1</td>\n",
" <td>7.526</td>\n",
" <td>7.460</td>\n",
" <td>7.592</td>\n",
" <td>1.44178</td>\n",
" <td>1.16374</td>\n",
" <td>0.79504</td>\n",
" <td>0.57941</td>\n",
" <td>0.44453</td>\n",
" <td>0.36171</td>\n",
" <td>2.73939</td>\n",
" </tr>\n",
" <tr>\n",
" <th>98</th>\n",
" <td>Greece</td>\n",
" <td>Western Europe</td>\n",
" <td>99</td>\n",
" <td>5.033</td>\n",
" <td>4.935</td>\n",
" <td>5.131</td>\n",
" <td>1.24886</td>\n",
" <td>0.75473</td>\n",
" <td>0.80029</td>\n",
" <td>0.05822</td>\n",
" <td>0.04127</td>\n",
" <td>0.00000</td>\n",
" <td>2.12944</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"0 Denmark Western Europe ... 0.36171 2.73939\n",
"98 Greece Western Europe ... 0.00000 2.12944\n",
"\n",
"[2 rows x 13 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"North America\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Lower Confidence Interval</th>\n",
" <th>Upper Confidence Interval</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Canada</td>\n",
" <td>North America</td>\n",
" <td>6</td>\n",
" <td>7.404</td>\n",
" <td>7.335</td>\n",
" <td>7.473</td>\n",
" <td>1.44015</td>\n",
" <td>1.09610</td>\n",
" <td>0.8276</td>\n",
" <td>0.57370</td>\n",
" <td>0.31329</td>\n",
" <td>0.44834</td>\n",
" <td>2.70485</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>United States</td>\n",
" <td>North America</td>\n",
" <td>13</td>\n",
" <td>7.104</td>\n",
" <td>7.020</td>\n",
" <td>7.188</td>\n",
" <td>1.50796</td>\n",
" <td>1.04782</td>\n",
" <td>0.7790</td>\n",
" <td>0.48163</td>\n",
" <td>0.14868</td>\n",
" <td>0.41077</td>\n",
" <td>2.72782</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"5 Canada North America ... 0.44834 2.70485\n",
"12 United States North America ... 0.41077 2.72782\n",
"\n",
"[2 rows x 13 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"Australia and New Zealand\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Lower Confidence Interval</th>\n",
" <th>Upper Confidence Interval</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>New Zealand</td>\n",
" <td>Australia and New Zealand</td>\n",
" <td>8</td>\n",
" <td>7.334</td>\n",
" <td>7.264</td>\n",
" <td>7.404</td>\n",
" <td>1.36066</td>\n",
" <td>1.17278</td>\n",
" <td>0.83096</td>\n",
" <td>0.58147</td>\n",
" <td>0.41904</td>\n",
" <td>0.49401</td>\n",
" <td>2.47553</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>Australia</td>\n",
" <td>Australia and New Zealand</td>\n",
" <td>9</td>\n",
" <td>7.313</td>\n",
" <td>7.241</td>\n",
" <td>7.385</td>\n",
" <td>1.44443</td>\n",
" <td>1.10476</td>\n",
" <td>0.85120</td>\n",
" <td>0.56837</td>\n",
" <td>0.32331</td>\n",
" <td>0.47407</td>\n",
" <td>2.54650</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"7 New Zealand Australia and New Zealand ... 0.49401 2.47553\n",
"8 Australia Australia and New Zealand ... 0.47407 2.54650\n",
"\n",
"[2 rows x 13 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"Middle East and Northern Africa\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Lower Confidence Interval</th>\n",
" <th>Upper Confidence Interval</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>Israel</td>\n",
" <td>Middle East and Northern Africa</td>\n",
" <td>11</td>\n",
" <td>7.267</td>\n",
" <td>7.199</td>\n",
" <td>7.335</td>\n",
" <td>1.33766</td>\n",
" <td>0.99537</td>\n",
" <td>0.84917</td>\n",
" <td>0.36432</td>\n",
" <td>0.08728</td>\n",
" <td>0.32288</td>\n",
" <td>3.31029</td>\n",
" </tr>\n",
" <tr>\n",
" <th>155</th>\n",
" <td>Syria</td>\n",
" <td>Middle East and Northern Africa</td>\n",
" <td>156</td>\n",
" <td>3.069</td>\n",
" <td>2.936</td>\n",
" <td>3.202</td>\n",
" <td>0.74719</td>\n",
" <td>0.14866</td>\n",
" <td>0.62994</td>\n",
" <td>0.06912</td>\n",
" <td>0.17233</td>\n",
" <td>0.48397</td>\n",
" <td>0.81789</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"10 Israel Middle East and Northern Africa ... 0.32288 3.31029\n",
"155 Syria Middle East and Northern Africa ... 0.48397 0.81789\n",
"\n",
"[2 rows x 13 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"Latin America and Caribbean\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Lower Confidence Interval</th>\n",
" <th>Upper Confidence Interval</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>Costa Rica</td>\n",
" <td>Latin America and Caribbean</td>\n",
" <td>14</td>\n",
" <td>7.087</td>\n",
" <td>6.999</td>\n",
" <td>7.175</td>\n",
" <td>1.06879</td>\n",
" <td>1.02152</td>\n",
" <td>0.76146</td>\n",
" <td>0.55225</td>\n",
" <td>0.10547</td>\n",
" <td>0.22553</td>\n",
" <td>3.35168</td>\n",
" </tr>\n",
" <tr>\n",
" <th>135</th>\n",
" <td>Haiti</td>\n",
" <td>Latin America and Caribbean</td>\n",
" <td>136</td>\n",
" <td>4.028</td>\n",
" <td>3.893</td>\n",
" <td>4.163</td>\n",
" <td>0.34097</td>\n",
" <td>0.29561</td>\n",
" <td>0.27494</td>\n",
" <td>0.12072</td>\n",
" <td>0.14476</td>\n",
" <td>0.47958</td>\n",
" <td>2.37116</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"13 Costa Rica Latin America and Caribbean ... 0.22553 3.35168\n",
"135 Haiti Latin America and Caribbean ... 0.47958 2.37116\n",
"\n",
"[2 rows x 13 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"Southeastern Asia\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Lower Confidence Interval</th>\n",
" <th>Upper Confidence Interval</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>Singapore</td>\n",
" <td>Southeastern Asia</td>\n",
" <td>22</td>\n",
" <td>6.739</td>\n",
" <td>6.674</td>\n",
" <td>6.804</td>\n",
" <td>1.64555</td>\n",
" <td>0.86758</td>\n",
" <td>0.94719</td>\n",
" <td>0.48770</td>\n",
" <td>0.46987</td>\n",
" <td>0.32706</td>\n",
" <td>1.99375</td>\n",
" </tr>\n",
" <tr>\n",
" <th>139</th>\n",
" <td>Cambodia</td>\n",
" <td>Southeastern Asia</td>\n",
" <td>140</td>\n",
" <td>3.907</td>\n",
" <td>3.798</td>\n",
" <td>4.016</td>\n",
" <td>0.55604</td>\n",
" <td>0.53750</td>\n",
" <td>0.42494</td>\n",
" <td>0.58852</td>\n",
" <td>0.08092</td>\n",
" <td>0.40339</td>\n",
" <td>1.31573</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"21 Singapore Southeastern Asia ... 0.32706 1.99375\n",
"139 Cambodia Southeastern Asia ... 0.40339 1.31573\n",
"\n",
"[2 rows x 13 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"Central and Eastern Europe\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Lower Confidence Interval</th>\n",
" <th>Upper Confidence Interval</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>Czech Republic</td>\n",
" <td>Central and Eastern Europe</td>\n",
" <td>27</td>\n",
" <td>6.596</td>\n",
" <td>6.515</td>\n",
" <td>6.677</td>\n",
" <td>1.30915</td>\n",
" <td>1.00793</td>\n",
" <td>0.76376</td>\n",
" <td>0.41418</td>\n",
" <td>0.03986</td>\n",
" <td>0.09929</td>\n",
" <td>2.96211</td>\n",
" </tr>\n",
" <tr>\n",
" <th>128</th>\n",
" <td>Bulgaria</td>\n",
" <td>Central and Eastern Europe</td>\n",
" <td>129</td>\n",
" <td>4.217</td>\n",
" <td>4.104</td>\n",
" <td>4.330</td>\n",
" <td>1.11306</td>\n",
" <td>0.92542</td>\n",
" <td>0.67806</td>\n",
" <td>0.21219</td>\n",
" <td>0.00615</td>\n",
" <td>0.12793</td>\n",
" <td>1.15377</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"26 Czech Republic Central and Eastern Europe ... 0.09929 2.96211\n",
"128 Bulgaria Central and Eastern Europe ... 0.12793 1.15377\n",
"\n",
"[2 rows x 13 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"Eastern Asia\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Lower Confidence Interval</th>\n",
" <th>Upper Confidence Interval</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>34</th>\n",
" <td>Taiwan</td>\n",
" <td>Eastern Asia</td>\n",
" <td>34</td>\n",
" <td>6.379</td>\n",
" <td>6.305</td>\n",
" <td>6.453</td>\n",
" <td>1.39729</td>\n",
" <td>0.92624</td>\n",
" <td>0.79565</td>\n",
" <td>0.32377</td>\n",
" <td>0.06630</td>\n",
" <td>0.25495</td>\n",
" <td>2.61523</td>\n",
" </tr>\n",
" <tr>\n",
" <th>100</th>\n",
" <td>Mongolia</td>\n",
" <td>Eastern Asia</td>\n",
" <td>101</td>\n",
" <td>4.907</td>\n",
" <td>4.838</td>\n",
" <td>4.976</td>\n",
" <td>0.98853</td>\n",
" <td>1.08983</td>\n",
" <td>0.55469</td>\n",
" <td>0.35972</td>\n",
" <td>0.03285</td>\n",
" <td>0.34539</td>\n",
" <td>1.53586</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"34 Taiwan Eastern Asia ... 0.25495 2.61523\n",
"100 Mongolia Eastern Asia ... 0.34539 1.53586\n",
"\n",
"[2 rows x 13 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"Sub-Saharan Africa\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Lower Confidence Interval</th>\n",
" <th>Upper Confidence Interval</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>65</th>\n",
" <td>Mauritius</td>\n",
" <td>Sub-Saharan Africa</td>\n",
" <td>66</td>\n",
" <td>5.648</td>\n",
" <td>5.507</td>\n",
" <td>5.789</td>\n",
" <td>1.14372</td>\n",
" <td>0.75695</td>\n",
" <td>0.66189</td>\n",
" <td>0.46145</td>\n",
" <td>0.05203</td>\n",
" <td>0.36951</td>\n",
" <td>2.20223</td>\n",
" </tr>\n",
" <tr>\n",
" <th>156</th>\n",
" <td>Burundi</td>\n",
" <td>Sub-Saharan Africa</td>\n",
" <td>157</td>\n",
" <td>2.905</td>\n",
" <td>2.732</td>\n",
" <td>3.078</td>\n",
" <td>0.06831</td>\n",
" <td>0.23442</td>\n",
" <td>0.15747</td>\n",
" <td>0.04320</td>\n",
" <td>0.09419</td>\n",
" <td>0.20290</td>\n",
" <td>2.10404</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"65 Mauritius Sub-Saharan Africa ... 0.36951 2.20223\n",
"156 Burundi Sub-Saharan Africa ... 0.20290 2.10404\n",
"\n",
"[2 rows x 13 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"Southern Asia\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Region</th>\n",
" <th>Happiness Rank</th>\n",
" <th>Happiness Score</th>\n",
" <th>Lower Confidence Interval</th>\n",
" <th>Upper Confidence Interval</th>\n",
" <th>Economy (GDP per Capita)</th>\n",
" <th>Family</th>\n",
" <th>Health (Life Expectancy)</th>\n",
" <th>Freedom</th>\n",
" <th>Trust (Government Corruption)</th>\n",
" <th>Generosity</th>\n",
" <th>Dystopia Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>83</th>\n",
" <td>Bhutan</td>\n",
" <td>Southern Asia</td>\n",
" <td>84</td>\n",
" <td>5.196</td>\n",
" <td>5.138</td>\n",
" <td>5.254</td>\n",
" <td>0.85270</td>\n",
" <td>0.90836</td>\n",
" <td>0.49759</td>\n",
" <td>0.46074</td>\n",
" <td>0.16160</td>\n",
" <td>0.48546</td>\n",
" <td>1.82916</td>\n",
" </tr>\n",
" <tr>\n",
" <th>153</th>\n",
" <td>Afghanistan</td>\n",
" <td>Southern Asia</td>\n",
" <td>154</td>\n",
" <td>3.360</td>\n",
" <td>3.288</td>\n",
" <td>3.432</td>\n",
" <td>0.38227</td>\n",
" <td>0.11037</td>\n",
" <td>0.17344</td>\n",
" <td>0.16430</td>\n",
" <td>0.07112</td>\n",
" <td>0.31268</td>\n",
" <td>2.14558</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Region ... Generosity Dystopia Residual\n",
"83 Bhutan Southern Asia ... 0.48546 1.82916\n",
"153 Afghanistan Southern Asia ... 0.31268 2.14558\n",
"\n",
"[2 rows x 13 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"In the Year 2017 \n",
"\n",
"Western Europe\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Happiness.Rank</th>\n",
" <th>Happiness.Score</th>\n",
" <th>Whisker.high</th>\n",
" <th>Whisker.low</th>\n",
" <th>Economy..GDP.per.Capita.</th>\n",
" <th>Family</th>\n",
" <th>Health..Life.Expectancy.</th>\n",
" <th>Freedom</th>\n",
" <th>Generosity</th>\n",
" <th>Trust..Government.Corruption.</th>\n",
" <th>Dystopia.Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Norway</td>\n",
" <td>1</td>\n",
" <td>7.537</td>\n",
" <td>7.594445</td>\n",
" <td>7.479556</td>\n",
" <td>1.616463</td>\n",
" <td>1.533524</td>\n",
" <td>0.796667</td>\n",
" <td>0.635423</td>\n",
" <td>0.362012</td>\n",
" <td>0.315964</td>\n",
" <td>2.277027</td>\n",
" </tr>\n",
" <tr>\n",
" <th>88</th>\n",
" <td>Portugal</td>\n",
" <td>89</td>\n",
" <td>5.195</td>\n",
" <td>5.285042</td>\n",
" <td>5.104959</td>\n",
" <td>1.315175</td>\n",
" <td>1.367043</td>\n",
" <td>0.795844</td>\n",
" <td>0.498465</td>\n",
" <td>0.095103</td>\n",
" <td>0.015869</td>\n",
" <td>1.107683</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Happiness.Rank ... Trust..Government.Corruption. Dystopia.Residual\n",
"0 Norway 1 ... 0.315964 2.277027\n",
"88 Portugal 89 ... 0.015869 1.107683\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n",
"North America\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Happiness.Rank</th>\n",
" <th>Happiness.Score</th>\n",
" <th>Whisker.high</th>\n",
" <th>Whisker.low</th>\n",
" <th>Economy..GDP.per.Capita.</th>\n",
" <th>Family</th>\n",
" <th>Health..Life.Expectancy.</th>\n",
" <th>Freedom</th>\n",
" <th>Generosity</th>\n",
" <th>Trust..Government.Corruption.</th>\n",
" <th>Dystopia.Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Canada</td>\n",
" <td>7</td>\n",
" <td>7.316</td>\n",
" <td>7.384403</td>\n",
" <td>7.247597</td>\n",
" <td>1.479204</td>\n",
" <td>1.481349</td>\n",
" <td>0.834558</td>\n",
" <td>0.611101</td>\n",
" <td>0.435540</td>\n",
" <td>0.287372</td>\n",
" <td>2.187264</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>United States</td>\n",
" <td>14</td>\n",
" <td>6.993</td>\n",
" <td>7.074657</td>\n",
" <td>6.911343</td>\n",
" <td>1.546259</td>\n",
" <td>1.419921</td>\n",
" <td>0.774287</td>\n",
" <td>0.505741</td>\n",
" <td>0.392579</td>\n",
" <td>0.135639</td>\n",
" <td>2.218113</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country ... Dystopia.Residual\n",
"6 Canada ... 2.187264\n",
"13 United States ... 2.218113\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n",
"Australia and New Zealand\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Happiness.Rank</th>\n",
" <th>Happiness.Score</th>\n",
" <th>Whisker.high</th>\n",
" <th>Whisker.low</th>\n",
" <th>Economy..GDP.per.Capita.</th>\n",
" <th>Family</th>\n",
" <th>Health..Life.Expectancy.</th>\n",
" <th>Freedom</th>\n",
" <th>Generosity</th>\n",
" <th>Trust..Government.Corruption.</th>\n",
" <th>Dystopia.Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>New Zealand</td>\n",
" <td>8</td>\n",
" <td>7.314</td>\n",
" <td>7.379510</td>\n",
" <td>7.248490</td>\n",
" <td>1.405706</td>\n",
" <td>1.548195</td>\n",
" <td>0.816760</td>\n",
" <td>0.614062</td>\n",
" <td>0.500005</td>\n",
" <td>0.382817</td>\n",
" <td>2.046456</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>Australia</td>\n",
" <td>10</td>\n",
" <td>7.284</td>\n",
" <td>7.356651</td>\n",
" <td>7.211349</td>\n",
" <td>1.484415</td>\n",
" <td>1.510042</td>\n",
" <td>0.843887</td>\n",
" <td>0.601607</td>\n",
" <td>0.477699</td>\n",
" <td>0.301184</td>\n",
" <td>2.065211</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country ... Dystopia.Residual\n",
"7 New Zealand ... 2.046456\n",
"9 Australia ... 2.065211\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n",
"Middle East and Northern Africa\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Happiness.Rank</th>\n",
" <th>Happiness.Score</th>\n",
" <th>Whisker.high</th>\n",
" <th>Whisker.low</th>\n",
" <th>Economy..GDP.per.Capita.</th>\n",
" <th>Family</th>\n",
" <th>Health..Life.Expectancy.</th>\n",
" <th>Freedom</th>\n",
" <th>Generosity</th>\n",
" <th>Trust..Government.Corruption.</th>\n",
" <th>Dystopia.Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>Israel</td>\n",
" <td>11</td>\n",
" <td>7.213</td>\n",
" <td>7.279853</td>\n",
" <td>7.146146</td>\n",
" <td>1.375382</td>\n",
" <td>1.376290</td>\n",
" <td>0.838404</td>\n",
" <td>0.405989</td>\n",
" <td>0.330083</td>\n",
" <td>0.085242</td>\n",
" <td>2.801757</td>\n",
" </tr>\n",
" <tr>\n",
" <th>151</th>\n",
" <td>Syria</td>\n",
" <td>152</td>\n",
" <td>3.462</td>\n",
" <td>3.663669</td>\n",
" <td>3.260331</td>\n",
" <td>0.777153</td>\n",
" <td>0.396103</td>\n",
" <td>0.500533</td>\n",
" <td>0.081539</td>\n",
" <td>0.493664</td>\n",
" <td>0.151347</td>\n",
" <td>1.061574</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Happiness.Rank ... Trust..Government.Corruption. Dystopia.Residual\n",
"10 Israel 11 ... 0.085242 2.801757\n",
"151 Syria 152 ... 0.151347 1.061574\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n",
"Latin America and Caribbean\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Happiness.Rank</th>\n",
" <th>Happiness.Score</th>\n",
" <th>Whisker.high</th>\n",
" <th>Whisker.low</th>\n",
" <th>Economy..GDP.per.Capita.</th>\n",
" <th>Family</th>\n",
" <th>Health..Life.Expectancy.</th>\n",
" <th>Freedom</th>\n",
" <th>Generosity</th>\n",
" <th>Trust..Government.Corruption.</th>\n",
" <th>Dystopia.Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>Costa Rica</td>\n",
" <td>12</td>\n",
" <td>7.079</td>\n",
" <td>7.168112</td>\n",
" <td>6.989888</td>\n",
" <td>1.109706</td>\n",
" <td>1.416404</td>\n",
" <td>0.759509</td>\n",
" <td>0.580132</td>\n",
" <td>0.214613</td>\n",
" <td>0.100107</td>\n",
" <td>2.898639</td>\n",
" </tr>\n",
" <tr>\n",
" <th>144</th>\n",
" <td>Haiti</td>\n",
" <td>145</td>\n",
" <td>3.603</td>\n",
" <td>3.734715</td>\n",
" <td>3.471285</td>\n",
" <td>0.368610</td>\n",
" <td>0.640450</td>\n",
" <td>0.277321</td>\n",
" <td>0.030370</td>\n",
" <td>0.489204</td>\n",
" <td>0.099872</td>\n",
" <td>1.697168</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country ... Dystopia.Residual\n",
"11 Costa Rica ... 2.898639\n",
"144 Haiti ... 1.697168\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n",
"Southeastern Asia\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Happiness.Rank</th>\n",
" <th>Happiness.Score</th>\n",
" <th>Whisker.high</th>\n",
" <th>Whisker.low</th>\n",
" <th>Economy..GDP.per.Capita.</th>\n",
" <th>Family</th>\n",
" <th>Health..Life.Expectancy.</th>\n",
" <th>Freedom</th>\n",
" <th>Generosity</th>\n",
" <th>Trust..Government.Corruption.</th>\n",
" <th>Dystopia.Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>Singapore</td>\n",
" <td>26</td>\n",
" <td>6.572</td>\n",
" <td>6.636723</td>\n",
" <td>6.507277</td>\n",
" <td>1.692278</td>\n",
" <td>1.353814</td>\n",
" <td>0.949492</td>\n",
" <td>0.549841</td>\n",
" <td>0.345966</td>\n",
" <td>0.464308</td>\n",
" <td>1.216362</td>\n",
" </tr>\n",
" <tr>\n",
" <th>128</th>\n",
" <td>Cambodia</td>\n",
" <td>129</td>\n",
" <td>4.168</td>\n",
" <td>4.278518</td>\n",
" <td>4.057483</td>\n",
" <td>0.601765</td>\n",
" <td>1.006238</td>\n",
" <td>0.429783</td>\n",
" <td>0.633376</td>\n",
" <td>0.385923</td>\n",
" <td>0.068106</td>\n",
" <td>1.042941</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country ... Dystopia.Residual\n",
"25 Singapore ... 1.216362\n",
"128 Cambodia ... 1.042941\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n",
"Central and Eastern Europe\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Happiness.Rank</th>\n",
" <th>Happiness.Score</th>\n",
" <th>Whisker.high</th>\n",
" <th>Whisker.low</th>\n",
" <th>Economy..GDP.per.Capita.</th>\n",
" <th>Family</th>\n",
" <th>Health..Life.Expectancy.</th>\n",
" <th>Freedom</th>\n",
" <th>Generosity</th>\n",
" <th>Trust..Government.Corruption.</th>\n",
" <th>Dystopia.Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>Czech Republic</td>\n",
" <td>23</td>\n",
" <td>6.609</td>\n",
" <td>6.683862</td>\n",
" <td>6.534138</td>\n",
" <td>1.352682</td>\n",
" <td>1.433885</td>\n",
" <td>0.754444</td>\n",
" <td>0.490946</td>\n",
" <td>0.088107</td>\n",
" <td>0.036873</td>\n",
" <td>2.451862</td>\n",
" </tr>\n",
" <tr>\n",
" <th>131</th>\n",
" <td>Ukraine</td>\n",
" <td>132</td>\n",
" <td>4.096</td>\n",
" <td>4.185410</td>\n",
" <td>4.006590</td>\n",
" <td>0.894652</td>\n",
" <td>1.394538</td>\n",
" <td>0.575904</td>\n",
" <td>0.122975</td>\n",
" <td>0.270061</td>\n",
" <td>0.023029</td>\n",
" <td>0.814382</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country ... Dystopia.Residual\n",
"22 Czech Republic ... 2.451862\n",
"131 Ukraine ... 0.814382\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n",
"Eastern Asia\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Happiness.Rank</th>\n",
" <th>Happiness.Score</th>\n",
" <th>Whisker.high</th>\n",
" <th>Whisker.low</th>\n",
" <th>Economy..GDP.per.Capita.</th>\n",
" <th>Family</th>\n",
" <th>Health..Life.Expectancy.</th>\n",
" <th>Freedom</th>\n",
" <th>Generosity</th>\n",
" <th>Trust..Government.Corruption.</th>\n",
" <th>Dystopia.Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>50</th>\n",
" <td>Japan</td>\n",
" <td>51</td>\n",
" <td>5.920</td>\n",
" <td>5.990719</td>\n",
" <td>5.849281</td>\n",
" <td>1.416915</td>\n",
" <td>1.436338</td>\n",
" <td>0.913476</td>\n",
" <td>0.505626</td>\n",
" <td>0.120573</td>\n",
" <td>0.163761</td>\n",
" <td>1.363224</td>\n",
" </tr>\n",
" <tr>\n",
" <th>99</th>\n",
" <td>Mongolia</td>\n",
" <td>100</td>\n",
" <td>4.955</td>\n",
" <td>5.021680</td>\n",
" <td>4.888320</td>\n",
" <td>1.027236</td>\n",
" <td>1.493011</td>\n",
" <td>0.557783</td>\n",
" <td>0.394144</td>\n",
" <td>0.338464</td>\n",
" <td>0.032902</td>\n",
" <td>1.111292</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Happiness.Rank ... Trust..Government.Corruption. Dystopia.Residual\n",
"50 Japan 51 ... 0.163761 1.363224\n",
"99 Mongolia 100 ... 0.032902 1.111292\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n",
"Sub-Saharan Africa\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Happiness.Rank</th>\n",
" <th>Happiness.Score</th>\n",
" <th>Whisker.high</th>\n",
" <th>Whisker.low</th>\n",
" <th>Economy..GDP.per.Capita.</th>\n",
" <th>Family</th>\n",
" <th>Health..Life.Expectancy.</th>\n",
" <th>Freedom</th>\n",
" <th>Generosity</th>\n",
" <th>Trust..Government.Corruption.</th>\n",
" <th>Dystopia.Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>63</th>\n",
" <td>Mauritius</td>\n",
" <td>64</td>\n",
" <td>5.629</td>\n",
" <td>5.729862</td>\n",
" <td>5.528138</td>\n",
" <td>1.189396</td>\n",
" <td>1.209561</td>\n",
" <td>0.638007</td>\n",
" <td>0.491247</td>\n",
" <td>0.360934</td>\n",
" <td>0.042182</td>\n",
" <td>1.697584</td>\n",
" </tr>\n",
" <tr>\n",
" <th>154</th>\n",
" <td>Central African Republic</td>\n",
" <td>155</td>\n",
" <td>2.693</td>\n",
" <td>2.864884</td>\n",
" <td>2.521116</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0.018773</td>\n",
" <td>0.270842</td>\n",
" <td>0.280876</td>\n",
" <td>0.056565</td>\n",
" <td>2.066005</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country ... Dystopia.Residual\n",
"63 Mauritius ... 1.697584\n",
"154 Central African Republic ... 2.066005\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n",
"Southern Asia\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Happiness.Rank</th>\n",
" <th>Happiness.Score</th>\n",
" <th>Whisker.high</th>\n",
" <th>Whisker.low</th>\n",
" <th>Economy..GDP.per.Capita.</th>\n",
" <th>Family</th>\n",
" <th>Health..Life.Expectancy.</th>\n",
" <th>Freedom</th>\n",
" <th>Generosity</th>\n",
" <th>Trust..Government.Corruption.</th>\n",
" <th>Dystopia.Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>79</th>\n",
" <td>Pakistan</td>\n",
" <td>80</td>\n",
" <td>5.269</td>\n",
" <td>5.359984</td>\n",
" <td>5.178016</td>\n",
" <td>0.726884</td>\n",
" <td>0.672691</td>\n",
" <td>0.402048</td>\n",
" <td>0.235215</td>\n",
" <td>0.315446</td>\n",
" <td>0.124348</td>\n",
" <td>2.792489</td>\n",
" </tr>\n",
" <tr>\n",
" <th>140</th>\n",
" <td>Afghanistan</td>\n",
" <td>141</td>\n",
" <td>3.794</td>\n",
" <td>3.873661</td>\n",
" <td>3.714338</td>\n",
" <td>0.401477</td>\n",
" <td>0.581543</td>\n",
" <td>0.180747</td>\n",
" <td>0.106180</td>\n",
" <td>0.311871</td>\n",
" <td>0.061158</td>\n",
" <td>2.150801</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country ... Dystopia.Residual\n",
"79 Pakistan ... 2.792489\n",
"140 Afghanistan ... 2.150801\n",
"\n",
"[2 rows x 12 columns]"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "1xTbfYrPD0XC",
"colab_type": "text"
},
"source": [
"# Question 4\n",
"\n",
"**4.Countries that became unhappy between 2015 to 2017** \n",
"\n",
"Happiness Score\n",
"\n",
"A metric measured in 2015 by asking the sampled people the question: \"How would you rate your happiness on a scale of 0 to 10 where 10 is the happiest.\"\n",
"\n",
"As per the Metric, All the countries above 5 are considered to be \"happy\" and all the countries below the score of 5 are considered to be \"unhappy\"."
]
},
{
"cell_type": "code",
"metadata": {
"id": "4nC62RAOSflj",
"colab_type": "code",
"colab": {}
},
"source": [
"def happiness_more_than_score(df,score):\n",
" \"\"\"Gathers the country names with happiness score greater than specified.\"\"\"\n",
" \n",
" if df.equals(df_2015):\n",
" return df_2015['Country'][df_2015['Happiness Score'] > score]\n",
" elif df.equals(df_2016):\n",
" return df_2016['Country'][df_2016['Happiness Score'] > score]\n",
" elif df.equals(df_2017):\n",
" return df_2017['Country'][df_2017['Happiness.Score'] > score]"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "2hOy7fcHBpPo",
"colab_type": "code",
"colab": {}
},
"source": [
""
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "1da6g3JEFBNz",
"colab_type": "text"
},
"source": [
"**Answer**"
]
},
{
"cell_type": "code",
"metadata": {
"id": "HlJs38zPEfwS",
"colab_type": "code",
"outputId": "073448a3-8891-41ad-bcfa-c8e4124ff325",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 80
}
},
"source": [
"## Run this cell ##\n",
"\n",
"df_happy = happiness_more_than_score(df_2015,5).to_frame()\n",
"df_unhappy = happiness_less_than_score(df_2017,5).to_frame() #from Question 1\n",
"\n",
"display(df_unhappy[df_unhappy['Country'].isin(df_happy['Country'])])\n"
],
"execution_count": 10,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>115</th>\n",
" <td>Zambia</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country\n",
"115 Zambia"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Q07fZ_krRAbw",
"colab_type": "text"
},
"source": [
"# Question 5\n",
"\n",
"5. Find the country whose happiness decreased by the most amount\n",
"\n",
"**Answer**"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "7xgVeGhaDzeh",
"colab_type": "text"
},
"source": [
""
]
},
{
"cell_type": "code",
"metadata": {
"id": "EtqKYWLrBqcu",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 80
},
"outputId": "e68e404b-d36b-49db-ce1f-75a0777920e9"
},
"source": [
"## Run this cell ##\n",
"\n",
"df_before = df_2015[['Country','Happiness Score']]\n",
"df_after = df_2017[['Country','Happiness.Score']]\n",
"df_merge = pd.merge(df_before,df_after, on='Country')\n",
"df_merge['difference'] = df_merge['Happiness.Score'] - df_merge['Happiness Score']\n",
"display(df_merge[df_merge['difference'] == df_merge['difference'].min()])"
],
"execution_count": 11,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Country</th>\n",
" <th>Happiness Score</th>\n",
" <th>Happiness.Score</th>\n",
" <th>difference</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>Venezuela</td>\n",
" <td>6.81</td>\n",
" <td>5.25</td>\n",
" <td>-1.56</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Country Happiness Score Happiness.Score difference\n",
"21 Venezuela 6.81 5.25 -1.56"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "mDHQGyPGL4DQ",
"colab_type": "text"
},
"source": [
"#Task 2\n",
"\n",
"In the same notebook write the script to download UDF101 and\n",
"bring the training dataset in this format: (Labels can be downloaded\n",
"from here)"
]
},
{
"cell_type": "code",
"metadata": {
"id": "IFEbl5VURGal",
"colab_type": "code",
"outputId": "fa004cf9-4ef5-4d0f-b52f-f20ec76b384b",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 136
}
},
"source": [
"!pip install pyunpack\n",
"!pip install patool\n",
"!pip install clint"
],
"execution_count": 12,
"outputs": [
{
"output_type": "stream",
"text": [
"Requirement already satisfied: pyunpack in /usr/local/lib/python3.6/dist-packages (0.2.1)\n",
"Requirement already satisfied: easyprocess in /usr/local/lib/python3.6/dist-packages (from pyunpack) (0.3)\n",
"Requirement already satisfied: entrypoint2 in /usr/local/lib/python3.6/dist-packages (from pyunpack) (0.2.1)\n",
"Requirement already satisfied: argparse in /usr/local/lib/python3.6/dist-packages (from entrypoint2->pyunpack) (1.4.0)\n",
"Requirement already satisfied: patool in /usr/local/lib/python3.6/dist-packages (1.12)\n",
"Requirement already satisfied: clint in /usr/local/lib/python3.6/dist-packages (0.5.1)\n",
"Requirement already satisfied: args in /usr/local/lib/python3.6/dist-packages (from clint) (0.1.0)\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "y8iOvPEUQpkl",
"colab_type": "text"
},
"source": [
"Importing and Downloading the files"
]
},
{
"cell_type": "code",
"metadata": {
"id": "uVWw1hiQB8dT",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 115,
"referenced_widgets": [
"f24a2c9e820b4249ab63654b9ef56604",
"e4dc73cf71714fd38dd09fd06a8608c7",
"652720149f1843cd964a3fae5a32b6d7",
"a5b643a5d4db43769c04ded49d2ba09e",
"2859a8220b6340fcba1862b35fbe5b91",
"cfa563330e4b45cd9a4197bdf9ec6757",
"838f5f7533314ade8fa3859ef7f46bf1",
"6a30b268827f42e78da55a27979ddf47",
"d15b4d02e1d84ce9b218dde279f11c59",
"446c92b5b92845249477c60af3f63faf",
"d63d7a10beab42179bcd6b4f5a433a49",
"771d95358ad64e9c8742e416e61261da",
"767d69f1b35e4df8bb4e718772c02b20",
"8741b1c90f514abc950d3cdf4d63b5bf",
"52f2278bb6f04526a08a75db50680708",
"15696888463a4d668d7ff7e4f5c93ee3"
]
},
"outputId": "4429783e-b475-4c92-f131-36186ff751f2"
},
"source": [
"import os\n",
"import requests\n",
"from tqdm.auto import tqdm\n",
"from pyunpack import Archive\n",
"from clint.textui import progress\n",
"import shutil\n",
"\n",
"labels_url = \"https://www.crcv.ucf.edu/data/UCF101/UCF101TrainTestSplits-RecognitionTask.zip\"\n",
"data_url = \"https://www.crcv.ucf.edu/data/UCF101/UCF101.rar\"\n",
"\n",
"\n",
"os.chdir('/content')\n",
"\n",
"# labels file zip download\n",
"r = requests.get(labels_url, stream=True)\n",
"file_name = labels_url.split('/')[-1]\n",
"with tqdm.wrapattr(open(file_name, \"wb\"), \"write\", miniters=1,\n",
" total=int(r.headers.get('content-length', 0)),\n",
" desc=file_name) as fout:\n",
" for chunk in r.iter_content(chunk_size=4096):\n",
" fout.write(chunk)\n",
"\n",
"os.chdir('/content')\n",
"\n",
"# data file zip download\n",
"r = requests.get(data_url, stream=True)\n",
"file_name = data_url.split('/')[-1]\n",
"with tqdm.wrapattr(open(file_name, \"wb\"), \"write\", miniters=1,\n",
" total=int(r.headers.get('content-length', 0)),\n",
" desc=file_name) as fout:\n",
" for chunk in r.iter_content(chunk_size=4096):\n",
" fout.write(chunk)\n",
"\n",
" "
],
"execution_count": 13,
"outputs": [
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f24a2c9e820b4249ab63654b9ef56604",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='UCF101TrainTestSplits-RecognitionTask.zip', max=113943.0,…"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d15b4d02e1d84ce9b218dde279f11c59",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='UCF101.rar', max=6932971618.0, style=ProgressStyle(descri…"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "I44l5JdWB82u",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "98b60e3a-d51f-4873-86f2-249705942754"
},
"source": [
"try:\n",
" Archive('UCF101.rar').extractall('/content')\n",
"except Exception:\n",
" print('The error is due to inconsistency in the rar to patool extractor The contents are safely extracted.')"
],
"execution_count": 14,
"outputs": [
{
"output_type": "stream",
"text": [
"The error is due to inconsistency in the rar to patool extractor The contents are safely extracted.\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "xEM2TjFNMwpR",
"colab_type": "code",
"colab": {}
},
"source": [
"try:\n",
" Archive('UCF101TrainTestSplits-RecognitionTask.zip').extractall('/content')\n",
"except Exception:\n",
" print('The error is due to inconsistency in the rar to patool extractor The contents are safely extracted.')"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "dapsXkoAMyZ0",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 51
},
"outputId": "f879a905-7cd4-452c-a0f7-07b0f8a32e0b"
},
"source": [
"\n",
"os.chdir('/content/ucfTrainTestlist')\n",
"ucf_file_list = os.listdir()\n",
"ucf_temp = ucf_file_list[0:-1]\n",
"\n",
"#Finding the names of the actions \n",
"with open(ucf_file_list[-1],'r') as f:\n",
" names = []\n",
" for file in f:\n",
" res = \"\".join(filter(lambda x: not x.isdigit(), file))\n",
" names.append(res.strip().replace('\\n',''))\n",
"#Root directory in content folder of the notebook\n",
"os.chdir('/content')\n",
"os.mkdir('ucf101_result')\n",
"\n",
"#Creating the subfolders of train and test \n",
"os.chdir('/content/ucf101_result')\n",
"for subroot in ucf_temp:\n",
" subrootname,subrootextension = os.path.splitext(subroot)\n",
" os.mkdir(subrootname)\n",
"\n",
"#Creating names of actions in every train and test folders\n",
"os.chdir('/content/ucf101_result')\n",
"for subroot in ucf_temp:\n",
" subrootname,subrootextension = os.path.splitext(subroot)\n",
" os.chdir('/content/ucf101_result/'+subrootname)\n",
" for name in names:\n",
" os.mkdir(name)\n",
"\n",
"print(\"File manipulation started... \")\n",
"#Loopoing through the videos of UCF-101 to compare with video in the Labels\n",
"for name in names:\n",
" os.chdir('/content/UCF-101/' + name)\n",
" videos = os.listdir()\n",
" for video in videos: # video in the UCF-101\n",
" for subroot in ucf_temp:\n",
" os.chdir('/content/ucfTrainTestlist')\n",
" subrootname,subrootextension = os.path.splitext(subroot)\n",
" with open(subroot,'r') as f:\n",
" for filepath in f:\n",
" filename = filepath.split('/')[-1].strip()\n",
" if( filename == video): # Comparison \n",
" shutil.move('/content/UCF-101/'+name+'/'+video,'/content/ucf101_result/'+subrootname+'/'+name)\n",
"\n",
"\n",
"\n",
"print(\"File manipulation complete.\")"
],
"execution_count": 16,
"outputs": [
{
"output_type": "stream",
"text": [
"File manipulation started... \n",
"File manipulation complete.\n"
],
"name": "stdout"
}
]
}
]
}