{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3f5b8052",
   "metadata": {},
   "source": [
    "# ASSIGNMENT 3\n",
    "\n",
    "* Madina Suraya Binti Zharin (A20EC0203)\n",
    "* Nur Irdina Aliah Binti Abdul Wahab (A20EC0115)\n",
    "* Adrina Asyiqin Md Adha (A20EC0174)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6331a8e9",
   "metadata": {},
   "source": [
    "## Question 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "0c9fa77c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "89386082",
   "metadata": {},
   "source": [
    "(a) Read the *“Diabetes Dataset.csv”* and save the data into a DataFrame.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "a0034071",
   "metadata": {},
   "outputs": [
    {
     "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>No_Times_Pregnant</th>\n",
       "      <th>Plasma_Glucose</th>\n",
       "      <th>Diastolic</th>\n",
       "      <th>Triceps</th>\n",
       "      <th>Insulin</th>\n",
       "      <th>BMI</th>\n",
       "      <th>Diabetes_Pedigree</th>\n",
       "      <th>Age</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>6.0</td>\n",
       "      <td>148.0</td>\n",
       "      <td>72.0</td>\n",
       "      <td>35.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>33.6</td>\n",
       "      <td>0.627</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1.0</td>\n",
       "      <td>85.0</td>\n",
       "      <td>66.0</td>\n",
       "      <td>29.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>26.6</td>\n",
       "      <td>0.351</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>8.0</td>\n",
       "      <td>183.0</td>\n",
       "      <td>64.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>23.3</td>\n",
       "      <td>0.672</td>\n",
       "      <td>32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1.0</td>\n",
       "      <td>89.0</td>\n",
       "      <td>66.0</td>\n",
       "      <td>23.0</td>\n",
       "      <td>94.0</td>\n",
       "      <td>28.1</td>\n",
       "      <td>0.167</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>NaN</td>\n",
       "      <td>137.0</td>\n",
       "      <td>40.0</td>\n",
       "      <td>35.0</td>\n",
       "      <td>168.0</td>\n",
       "      <td>43.1</td>\n",
       "      <td>2.288</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   No_Times_Pregnant  Plasma_Glucose  Diastolic  Triceps  Insulin   BMI  \\\n",
       "0                6.0           148.0       72.0     35.0      NaN  33.6   \n",
       "1                1.0            85.0       66.0     29.0      NaN  26.6   \n",
       "2                8.0           183.0       64.0      NaN      NaN  23.3   \n",
       "3                1.0            89.0       66.0     23.0     94.0  28.1   \n",
       "4                NaN           137.0       40.0     35.0    168.0  43.1   \n",
       "\n",
       "   Diabetes_Pedigree  Age  \n",
       "0              0.627   50  \n",
       "1              0.351   31  \n",
       "2              0.672   32  \n",
       "3              0.167   21  \n",
       "4              2.288   33  "
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = pd.read_csv(\"Diabetes Dataset.csv\")\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "37c0ace8",
   "metadata": {},
   "source": [
    "(b) What is the shape of the DataFrame?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "8f127f02",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(768, 8)"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3fd9b95c",
   "metadata": {},
   "source": [
    "(c) Get the number of missing values for each column."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "9368c44a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "No_Times_Pregnant    111\n",
       "Plasma_Glucose         7\n",
       "Diastolic             36\n",
       "Triceps              228\n",
       "Insulin              375\n",
       "BMI                   14\n",
       "Diabetes_Pedigree      1\n",
       "Age                    0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.isna().sum()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "eb3ed774",
   "metadata": {},
   "source": [
    "(d) Fill in all the missing values in column *No_Times_Pregnant* with value 1."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "035a471b",
   "metadata": {},
   "outputs": [],
   "source": [
    "data['No_Times_Pregnant'].fillna(1, inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "11b1ec27",
   "metadata": {},
   "source": [
    "(e) Drop all rows which contains less than 4 observation values."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "0df536e3",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = data.dropna(thresh=4)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3d88fbdb",
   "metadata": {},
   "source": [
    "(f) Fill in all the missing values in below columns with the given values or methods.\n",
    "\n",
    "| Column Name | Value/Method | \n",
    "| :-: | :-: |\n",
    "| Plasma_Glucose | Mean |\n",
    "| Diastolic | Forward Fill |\n",
    "| Triceps | Backward Fill |\n",
    "| Insulin | Mean|\n",
    "| BMI | Median |"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "87dda7f9",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = data.fillna({'Plasma_Glucose': data['Plasma_Glucose'].mean(), \n",
    "                    'Diastolic':data['Diastolic'].fillna(method='ffill'), \n",
    "                    'Triceps':data['Triceps'].fillna(method='bfill'),\n",
    "                    'Insulin':data['Insulin'].mean(), \n",
    "                    'BMI': data['BMI'].median()})"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fc58ddfb",
   "metadata": {},
   "source": [
    "(g) Check back the number of missing values for each column. It should now be 0 for all the \n",
    "columns."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "c123b8dc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "No_Times_Pregnant    0\n",
       "Plasma_Glucose       0\n",
       "Diastolic            0\n",
       "Triceps              0\n",
       "Insulin              0\n",
       "BMI                  0\n",
       "Diabetes_Pedigree    0\n",
       "Age                  0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.isna().sum()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6835b8ac",
   "metadata": {},
   "source": [
    "(h) Bin the age into below categories.\n",
    "\n",
    "| Age Category | \n",
    "| :-: |\n",
    "| 20 ≤ Age < 30 |\n",
    "| 30 ≤ Age < 40 |\n",
    "| 30 ≤ Age < 40 |\n",
    "| 50 ≤ Age < 60 |\n",
    "| 60 ≤ Age < 70 |\n",
    "| 70 ≤ Age < 80 |\n",
    "| 80 ≤ Age < 90 |"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "e6e17bbb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      (49, 59]\n",
       "1      (29, 39]\n",
       "2      (29, 39]\n",
       "3      (19, 29]\n",
       "4      (29, 39]\n",
       "         ...   \n",
       "763    (59, 69]\n",
       "764    (19, 29]\n",
       "765    (29, 39]\n",
       "766    (39, 49]\n",
       "767    (19, 29]\n",
       "Name: Age, Length: 765, dtype: category\n",
       "Categories (7, interval[int64, right]): [(19, 29] < (29, 39] < (39, 49] < (49, 59] < (59, 69] < (69, 79] < (79, 89]]"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bins = [19, 29, 39, 49, 59, 69, 79, 89]\n",
    "cats = pd.cut(data['Age'], bins)\n",
    "cats"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "52b65eb0",
   "metadata": {},
   "source": [
    "How many patients with diabetes for each category?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "30db3d80",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(19, 29]    395\n",
       "(29, 39]    163\n",
       "(39, 49]    118\n",
       "(49, 59]     57\n",
       "(59, 69]     29\n",
       "(69, 79]      2\n",
       "(79, 89]      1\n",
       "Name: Age, dtype: int64"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.value_counts(cats)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "00ee22f9",
   "metadata": {},
   "source": [
    "## Question 2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "37c4b330",
   "metadata": {},
   "source": [
    "(a) Read the “Live births by state and sex.xlsx” and save the data into a DataFrame."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "48a4afc3",
   "metadata": {},
   "outputs": [],
   "source": [
    "data1 = pd.read_excel('Live births by state and sex.xlsx')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "f800e042",
   "metadata": {},
   "outputs": [
    {
     "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>Year</th>\n",
       "      <th>State</th>\n",
       "      <th>Sex</th>\n",
       "      <th>Number of Live births</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2018</td>\n",
       "      <td>Johor</td>\n",
       "      <td>Female</td>\n",
       "      <td>29428</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2018</td>\n",
       "      <td>Johor</td>\n",
       "      <td>Male</td>\n",
       "      <td>31656</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2018</td>\n",
       "      <td>Kedah</td>\n",
       "      <td>Female</td>\n",
       "      <td>17181</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2018</td>\n",
       "      <td>Kedah</td>\n",
       "      <td>Male</td>\n",
       "      <td>18462</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2018</td>\n",
       "      <td>Kelantan</td>\n",
       "      <td>Female</td>\n",
       "      <td>18376</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Year     State     Sex  Number of Live births\n",
       "0  2018     Johor  Female                  29428\n",
       "1  2018     Johor    Male                  31656\n",
       "2  2018     Kedah  Female                  17181\n",
       "3  2018     Kedah    Male                  18462\n",
       "4  2018  Kelantan  Female                  18376"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data1.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b74c99a1",
   "metadata": {},
   "source": [
    "(b) Read another file named “Death by state and sex.xlsx” and save it into another DataFrame."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "6914b9fe",
   "metadata": {},
   "outputs": [
    {
     "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>Year</th>\n",
       "      <th>State</th>\n",
       "      <th>Sex</th>\n",
       "      <th>Number of death</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2018</td>\n",
       "      <td>Johor</td>\n",
       "      <td>Female</td>\n",
       "      <td>8733</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2018</td>\n",
       "      <td>Johor</td>\n",
       "      <td>Male</td>\n",
       "      <td>12384</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2018</td>\n",
       "      <td>Kedah</td>\n",
       "      <td>Female</td>\n",
       "      <td>6336</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2018</td>\n",
       "      <td>Kedah</td>\n",
       "      <td>Male</td>\n",
       "      <td>8216</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2018</td>\n",
       "      <td>Kelantan</td>\n",
       "      <td>Female</td>\n",
       "      <td>4984</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Year     State     Sex  Number of death\n",
       "0  2018     Johor  Female             8733\n",
       "1  2018     Johor    Male            12384\n",
       "2  2018     Kedah  Female             6336\n",
       "3  2018     Kedah    Male             8216\n",
       "4  2018  Kelantan  Female             4984"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data2 = pd.read_excel('Death by state and sex.xlsx')\n",
    "data2.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b13b5074",
   "metadata": {},
   "source": [
    "(c) Merge both files."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "da6c5e2f",
   "metadata": {},
   "outputs": [],
   "source": [
    "data3 = pd.merge(data1,data2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "ba2ebb9f",
   "metadata": {},
   "outputs": [
    {
     "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>Year</th>\n",
       "      <th>State</th>\n",
       "      <th>Sex</th>\n",
       "      <th>Number of Live births</th>\n",
       "      <th>Number of death</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2018</td>\n",
       "      <td>Johor</td>\n",
       "      <td>Female</td>\n",
       "      <td>29428</td>\n",
       "      <td>8733</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2018</td>\n",
       "      <td>Johor</td>\n",
       "      <td>Male</td>\n",
       "      <td>31656</td>\n",
       "      <td>12384</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2018</td>\n",
       "      <td>Kedah</td>\n",
       "      <td>Female</td>\n",
       "      <td>17181</td>\n",
       "      <td>6336</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2018</td>\n",
       "      <td>Kedah</td>\n",
       "      <td>Male</td>\n",
       "      <td>18462</td>\n",
       "      <td>8216</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2018</td>\n",
       "      <td>Kelantan</td>\n",
       "      <td>Female</td>\n",
       "      <td>18376</td>\n",
       "      <td>4984</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>299</th>\n",
       "      <td>2009</td>\n",
       "      <td>Terengganu</td>\n",
       "      <td>Male</td>\n",
       "      <td>12152</td>\n",
       "      <td>3491</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>300</th>\n",
       "      <td>2009</td>\n",
       "      <td>W.P. Kuala Lumpur</td>\n",
       "      <td>Female</td>\n",
       "      <td>12612</td>\n",
       "      <td>2662</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>301</th>\n",
       "      <td>2009</td>\n",
       "      <td>W.P. Kuala Lumpur</td>\n",
       "      <td>Male</td>\n",
       "      <td>13252</td>\n",
       "      <td>3808</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>302</th>\n",
       "      <td>2009</td>\n",
       "      <td>W.P. Labuan</td>\n",
       "      <td>Female</td>\n",
       "      <td>804</td>\n",
       "      <td>94</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>303</th>\n",
       "      <td>2009</td>\n",
       "      <td>W.P. Labuan</td>\n",
       "      <td>Male</td>\n",
       "      <td>845</td>\n",
       "      <td>153</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>304 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     Year              State     Sex  Number of Live births  Number of death\n",
       "0    2018              Johor  Female                  29428             8733\n",
       "1    2018              Johor    Male                  31656            12384\n",
       "2    2018              Kedah  Female                  17181             6336\n",
       "3    2018              Kedah    Male                  18462             8216\n",
       "4    2018           Kelantan  Female                  18376             4984\n",
       "..    ...                ...     ...                    ...              ...\n",
       "299  2009         Terengganu    Male                  12152             3491\n",
       "300  2009  W.P. Kuala Lumpur  Female                  12612             2662\n",
       "301  2009  W.P. Kuala Lumpur    Male                  13252             3808\n",
       "302  2009        W.P. Labuan  Female                    804               94\n",
       "303  2009        W.P. Labuan    Male                    845              153\n",
       "\n",
       "[304 rows x 5 columns]"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "7073f572",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Year                      int64\n",
       "State                    object\n",
       "Sex                      object\n",
       "Number of Live births     int64\n",
       "Number of death           int64\n",
       "dtype: object"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data3.dtypes"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7923d731",
   "metadata": {},
   "source": [
    "(d) Set the index."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "f9f2bed5",
   "metadata": {},
   "outputs": [
    {
     "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></th>\n",
       "      <th>Sex</th>\n",
       "      <th>Number of Live births</th>\n",
       "      <th>Number of death</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Year</th>\n",
       "      <th>State</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">2018</th>\n",
       "      <th>Johor</th>\n",
       "      <td>Female</td>\n",
       "      <td>29428</td>\n",
       "      <td>8733</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Johor</th>\n",
       "      <td>Male</td>\n",
       "      <td>31656</td>\n",
       "      <td>12384</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Kedah</th>\n",
       "      <td>Female</td>\n",
       "      <td>17181</td>\n",
       "      <td>6336</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Kedah</th>\n",
       "      <td>Male</td>\n",
       "      <td>18462</td>\n",
       "      <td>8216</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Kelantan</th>\n",
       "      <td>Female</td>\n",
       "      <td>18376</td>\n",
       "      <td>4984</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">2009</th>\n",
       "      <th>Terengganu</th>\n",
       "      <td>Male</td>\n",
       "      <td>12152</td>\n",
       "      <td>3491</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>W.P. Kuala Lumpur</th>\n",
       "      <td>Female</td>\n",
       "      <td>12612</td>\n",
       "      <td>2662</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>W.P. Kuala Lumpur</th>\n",
       "      <td>Male</td>\n",
       "      <td>13252</td>\n",
       "      <td>3808</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>W.P. Labuan</th>\n",
       "      <td>Female</td>\n",
       "      <td>804</td>\n",
       "      <td>94</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>W.P. Labuan</th>\n",
       "      <td>Male</td>\n",
       "      <td>845</td>\n",
       "      <td>153</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>304 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                           Sex  Number of Live births  Number of death\n",
       "Year State                                                            \n",
       "2018 Johor              Female                  29428             8733\n",
       "     Johor                Male                  31656            12384\n",
       "     Kedah              Female                  17181             6336\n",
       "     Kedah                Male                  18462             8216\n",
       "     Kelantan           Female                  18376             4984\n",
       "...                        ...                    ...              ...\n",
       "2009 Terengganu           Male                  12152             3491\n",
       "     W.P. Kuala Lumpur  Female                  12612             2662\n",
       "     W.P. Kuala Lumpur    Male                  13252             3808\n",
       "     W.P. Labuan        Female                    804               94\n",
       "     W.P. Labuan          Male                    845              153\n",
       "\n",
       "[304 rows x 3 columns]"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data3 = data3.set_index(['Year','State'])\n",
    "data3"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "63f64040",
   "metadata": {},
   "source": [
    "(e) Display the number of live births and number of deaths for all the years (2009-2018)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "008922da",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\adhas\\AppData\\Local\\Temp\\ipykernel_19468\\3964973193.py:1: FutureWarning: Indexing with multiple keys (implicitly converted to a tuple of keys) will be deprecated, use a list instead.\n",
      "  data3.groupby(\"Year\")['Number of Live births','Number of death'].sum().sort_index(ascending=False)\n"
     ]
    },
    {
     "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>Number of Live births</th>\n",
       "      <th>Number of death</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Year</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018</th>\n",
       "      <td>501945</td>\n",
       "      <td>172031</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017</th>\n",
       "      <td>276496</td>\n",
       "      <td>94694</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016</th>\n",
       "      <td>508203</td>\n",
       "      <td>162201</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015</th>\n",
       "      <td>521136</td>\n",
       "      <td>155786</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014</th>\n",
       "      <td>528612</td>\n",
       "      <td>150318</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013</th>\n",
       "      <td>476897</td>\n",
       "      <td>133949</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2012</th>\n",
       "      <td>499015</td>\n",
       "      <td>130626</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011</th>\n",
       "      <td>511594</td>\n",
       "      <td>127368</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010</th>\n",
       "      <td>437605</td>\n",
       "      <td>123356</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2009</th>\n",
       "      <td>496313</td>\n",
       "      <td>123763</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Number of Live births  Number of death\n",
       "Year                                        \n",
       "2018                 501945           172031\n",
       "2017                 276496            94694\n",
       "2016                 508203           162201\n",
       "2015                 521136           155786\n",
       "2014                 528612           150318\n",
       "2013                 476897           133949\n",
       "2012                 499015           130626\n",
       "2011                 511594           127368\n",
       "2010                 437605           123356\n",
       "2009                 496313           123763"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data3.groupby(\"Year\")['Number of Live births','Number of death'].sum().sort_index(ascending=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c16f14e5",
   "metadata": {},
   "source": [
    "(f) Swap the level."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "df838bcf",
   "metadata": {},
   "outputs": [
    {
     "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></th>\n",
       "      <th>Sex</th>\n",
       "      <th>Number of Live births</th>\n",
       "      <th>Number of death</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>State</th>\n",
       "      <th>Year</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">Johor</th>\n",
       "      <th>2009</th>\n",
       "      <td>Female</td>\n",
       "      <td>27386</td>\n",
       "      <td>6587</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2009</th>\n",
       "      <td>Male</td>\n",
       "      <td>29631</td>\n",
       "      <td>9384</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011</th>\n",
       "      <td>Female</td>\n",
       "      <td>28205</td>\n",
       "      <td>6875</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011</th>\n",
       "      <td>Male</td>\n",
       "      <td>29962</td>\n",
       "      <td>9604</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2012</th>\n",
       "      <td>Female</td>\n",
       "      <td>29230</td>\n",
       "      <td>7212</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">W.P. Putrajaya</th>\n",
       "      <th>2016</th>\n",
       "      <td>Male</td>\n",
       "      <td>1342</td>\n",
       "      <td>86</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017</th>\n",
       "      <td>Female</td>\n",
       "      <td>1219</td>\n",
       "      <td>106</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017</th>\n",
       "      <td>Male</td>\n",
       "      <td>1298</td>\n",
       "      <td>123</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018</th>\n",
       "      <td>Female</td>\n",
       "      <td>1149</td>\n",
       "      <td>98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018</th>\n",
       "      <td>Male</td>\n",
       "      <td>1251</td>\n",
       "      <td>120</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>304 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                        Sex  Number of Live births  Number of death\n",
       "State          Year                                                \n",
       "Johor          2009  Female                  27386             6587\n",
       "               2009    Male                  29631             9384\n",
       "               2011  Female                  28205             6875\n",
       "               2011    Male                  29962             9604\n",
       "               2012  Female                  29230             7212\n",
       "...                     ...                    ...              ...\n",
       "W.P. Putrajaya 2016    Male                   1342               86\n",
       "               2017  Female                   1219              106\n",
       "               2017    Male                   1298              123\n",
       "               2018  Female                   1149               98\n",
       "               2018    Male                   1251              120\n",
       "\n",
       "[304 rows x 3 columns]"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data3.swaplevel(0, 1).sort_index(level=0)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e609f39d",
   "metadata": {},
   "source": [
    "(g) Display the number of live births and number of deaths for all states."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "a9723ccf",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\adhas\\AppData\\Local\\Temp\\ipykernel_19468\\2322415651.py:1: FutureWarning: Indexing with multiple keys (implicitly converted to a tuple of keys) will be deprecated, use a list instead.\n",
      "  data3.groupby('State')['Number of Live births','Number of death'].sum().sort_index()\n"
     ]
    },
    {
     "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>Number of Live births</th>\n",
       "      <th>Number of death</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>State</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Johor</th>\n",
       "      <td>474661</td>\n",
       "      <td>145145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Kedah</th>\n",
       "      <td>323149</td>\n",
       "      <td>114959</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Kelantan</th>\n",
       "      <td>377024</td>\n",
       "      <td>104573</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Melaka</th>\n",
       "      <td>140550</td>\n",
       "      <td>48684</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Negeri Sembilan</th>\n",
       "      <td>178570</td>\n",
       "      <td>63879</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Pahang</th>\n",
       "      <td>244748</td>\n",
       "      <td>73795</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Perak</th>\n",
       "      <td>360604</td>\n",
       "      <td>168525</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Perlis</th>\n",
       "      <td>42714</td>\n",
       "      <td>17664</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Pulau Pinang</th>\n",
       "      <td>220445</td>\n",
       "      <td>98109</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Sabah</th>\n",
       "      <td>439363</td>\n",
       "      <td>51473</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Sarawak</th>\n",
       "      <td>404715</td>\n",
       "      <td>118670</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Selangor</th>\n",
       "      <td>1042680</td>\n",
       "      <td>225139</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Terengganu</th>\n",
       "      <td>234401</td>\n",
       "      <td>57769</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>W.P. Kuala Lumpur</th>\n",
       "      <td>231038</td>\n",
       "      <td>65858</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>W.P. Labuan</th>\n",
       "      <td>15797</td>\n",
       "      <td>2279</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>W.P. Putrajaya</th>\n",
       "      <td>27357</td>\n",
       "      <td>17571</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   Number of Live births  Number of death\n",
       "State                                                    \n",
       "Johor                             474661           145145\n",
       "Kedah                             323149           114959\n",
       "Kelantan                          377024           104573\n",
       "Melaka                            140550            48684\n",
       "Negeri Sembilan                   178570            63879\n",
       "Pahang                            244748            73795\n",
       "Perak                             360604           168525\n",
       "Perlis                             42714            17664\n",
       "Pulau Pinang                      220445            98109\n",
       "Sabah                             439363            51473\n",
       "Sarawak                           404715           118670\n",
       "Selangor                         1042680           225139\n",
       "Terengganu                        234401            57769\n",
       "W.P. Kuala Lumpur                 231038            65858\n",
       "W.P. Labuan                        15797             2279\n",
       "W.P. Putrajaya                     27357            17571"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data3.groupby('State')['Number of Live births','Number of death'].sum().sort_index()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "532a10e2",
   "metadata": {},
   "source": [
    "(h) Bin the age into below categories.\n",
    "\n",
    "| Age Category | \n",
    "| :-: |\n",
    "| 20 ≤ Age < 30 |\n",
    "| 30 ≤ Age < 40 |\n",
    "| 30 ≤ Age < 40 |\n",
    "| 50 ≤ Age < 60 |\n",
    "| 60 ≤ Age < 70 |\n",
    "| 70 ≤ Age < 80 |\n",
    "| 80 ≤ Age < 90 |"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "b3fb918a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      (49, 59]\n",
       "1      (29, 39]\n",
       "2      (29, 39]\n",
       "3      (19, 29]\n",
       "4      (29, 39]\n",
       "         ...   \n",
       "763    (59, 69]\n",
       "764    (19, 29]\n",
       "765    (29, 39]\n",
       "766    (39, 49]\n",
       "767    (19, 29]\n",
       "Name: Age, Length: 765, dtype: category\n",
       "Categories (7, interval[int64, right]): [(19, 29] < (29, 39] < (39, 49] < (49, 59] < (59, 69] < (69, 79] < (79, 89]]"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bins = [19, 29, 39, 49, 59, 69, 79, 89]\n",
    "cats = pd.cut(data['Age'], bins)\n",
    "cats"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "615c160d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "f8a51432",
   "metadata": {},
   "source": [
    "## Question 3"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a3f15ded",
   "metadata": {},
   "source": [
    "(a) Read the dataset and save into a data frame named tallest. Display the first 8 rows of the data frame."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "a660c403",
   "metadata": {},
   "outputs": [
    {
     "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>Category</th>\n",
       "      <th>Structure</th>\n",
       "      <th>Country</th>\n",
       "      <th>City</th>\n",
       "      <th>Height (meters)</th>\n",
       "      <th>Height (feet)</th>\n",
       "      <th>Year built</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Building[5]</td>\n",
       "      <td>Burj Khalifa</td>\n",
       "      <td>United Arab Emirates</td>\n",
       "      <td>Dubai</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2722.0</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Compliant tower</td>\n",
       "      <td>Petronius</td>\n",
       "      <td>United States</td>\n",
       "      <td>Gulf of Mexico</td>\n",
       "      <td>640.0</td>\n",
       "      <td>2100.0</td>\n",
       "      <td>2000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Self-supporting tower[6]</td>\n",
       "      <td>Tokyo Skytree</td>\n",
       "      <td>Japan</td>\n",
       "      <td>Tokyo</td>\n",
       "      <td>634.0</td>\n",
       "      <td>2080.0</td>\n",
       "      <td>2011</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Guyed steel lattice mast</td>\n",
       "      <td>KVLY-TV mast</td>\n",
       "      <td>United States</td>\n",
       "      <td>Blanchard, North Dakota</td>\n",
       "      <td>629.0</td>\n",
       "      <td>2063.0</td>\n",
       "      <td>1963</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Hyperboloid structure</td>\n",
       "      <td>Canton Tower</td>\n",
       "      <td>China</td>\n",
       "      <td>Guangzhou</td>\n",
       "      <td>604.0</td>\n",
       "      <td>1982.0</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Clock tower</td>\n",
       "      <td>Abraj Al Bait</td>\n",
       "      <td>Saudi Arabia</td>\n",
       "      <td>Mecca</td>\n",
       "      <td>601.0</td>\n",
       "      <td>1972.0</td>\n",
       "      <td>2012</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Fixed steel structure</td>\n",
       "      <td>Bullwinkle</td>\n",
       "      <td>United States</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Moveable object</td>\n",
       "      <td>Troll A platform</td>\n",
       "      <td>Norway</td>\n",
       "      <td>North Sea</td>\n",
       "      <td>472.0</td>\n",
       "      <td>1549.0</td>\n",
       "      <td>1996</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   Category         Structure               Country  \\\n",
       "0               Building[5]      Burj Khalifa  United Arab Emirates   \n",
       "1           Compliant tower         Petronius         United States   \n",
       "2  Self-supporting tower[6]     Tokyo Skytree                 Japan   \n",
       "3  Guyed steel lattice mast      KVLY-TV mast         United States   \n",
       "4     Hyperboloid structure      Canton Tower                 China   \n",
       "5               Clock tower     Abraj Al Bait          Saudi Arabia   \n",
       "6     Fixed steel structure        Bullwinkle         United States   \n",
       "7           Moveable object  Troll A platform                Norway   \n",
       "\n",
       "                      City  Height (meters)  Height (feet) Year built  \n",
       "0                    Dubai              NaN         2722.0       2010  \n",
       "1           Gulf of Mexico            640.0         2100.0       2000  \n",
       "2                    Tokyo            634.0         2080.0       2011  \n",
       "3  Blanchard, North Dakota            629.0         2063.0       1963  \n",
       "4                Guangzhou            604.0         1982.0       2010  \n",
       "5                    Mecca            601.0         1972.0       2012  \n",
       "6                      NaN              NaN            NaN        NaN  \n",
       "7                North Sea            472.0         1549.0       1996  "
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tallest = pd.read_csv('Tallest Building.csv')\n",
    "tallest.head(8)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2a7ca15b",
   "metadata": {},
   "source": [
    "(b) Find the number of rows and columns in tallest."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "9543a96e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of rows: 56\n",
      "Number of columns: 7\n"
     ]
    }
   ],
   "source": [
    "print('Number of rows:',len(tallest))\n",
    "print('Number of columns:',len(tallest.columns))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "528c024b",
   "metadata": {},
   "source": [
    "(c) Find which columns have missing values and how many of them?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "f4dcea4d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Columns with missing values\n",
      "Index(['Category', 'Country', 'City', 'Height (meters)', 'Height (feet)',\n",
      "       'Year built'],\n",
      "      dtype='object')\n",
      "\n",
      "Number of missing values in each column\n",
      "Category           1\n",
      "Structure          0\n",
      "Country            2\n",
      "City               7\n",
      "Height (meters)    8\n",
      "Height (feet)      2\n",
      "Year built         3\n",
      "dtype: int64\n"
     ]
    }
   ],
   "source": [
    "#columns names that have missing value\n",
    "print('Columns with missing values')\n",
    "print(tallest.columns[tallest.isnull().any()])\n",
    "\n",
    "#Number of missing values in each column\n",
    "print()\n",
    "print('Number of missing values in each column')\n",
    "print(tallest.isna().sum())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "84b2f0af",
   "metadata": {},
   "source": [
    "(d) Is there any duplicated data? Permanently remove the duplicate data if any."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "5ed284ef",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "No. of duplicated data: 4\n"
     ]
    }
   ],
   "source": [
    "print('No. of duplicated data:' ,(tallest.duplicated().sum()))\n",
    "\n",
    "#drop duplicate data\n",
    "tallest=tallest.drop_duplicates()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b6cff746",
   "metadata": {},
   "source": [
    "(e) Permanently delete all rows which contains at most three-observation data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "0e1d71c3",
   "metadata": {},
   "outputs": [
    {
     "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>Category</th>\n",
       "      <th>Structure</th>\n",
       "      <th>Country</th>\n",
       "      <th>City</th>\n",
       "      <th>Height (meters)</th>\n",
       "      <th>Height (feet)</th>\n",
       "      <th>Year built</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Building[5]</td>\n",
       "      <td>Burj Khalifa</td>\n",
       "      <td>United Arab Emirates</td>\n",
       "      <td>Dubai</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2722.0</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Compliant tower</td>\n",
       "      <td>Petronius</td>\n",
       "      <td>United States</td>\n",
       "      <td>Gulf of Mexico</td>\n",
       "      <td>640.00</td>\n",
       "      <td>2100.0</td>\n",
       "      <td>2000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Self-supporting tower[6]</td>\n",
       "      <td>Tokyo Skytree</td>\n",
       "      <td>Japan</td>\n",
       "      <td>Tokyo</td>\n",
       "      <td>634.00</td>\n",
       "      <td>2080.0</td>\n",
       "      <td>2011</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Guyed steel lattice mast</td>\n",
       "      <td>KVLY-TV mast</td>\n",
       "      <td>United States</td>\n",
       "      <td>Blanchard, North Dakota</td>\n",
       "      <td>629.00</td>\n",
       "      <td>2063.0</td>\n",
       "      <td>1963</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Hyperboloid structure</td>\n",
       "      <td>Canton Tower</td>\n",
       "      <td>China</td>\n",
       "      <td>Guangzhou</td>\n",
       "      <td>604.00</td>\n",
       "      <td>1982.0</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Clock tower</td>\n",
       "      <td>Abraj Al Bait</td>\n",
       "      <td>Saudi Arabia</td>\n",
       "      <td>Mecca</td>\n",
       "      <td>601.00</td>\n",
       "      <td>1972.0</td>\n",
       "      <td>2012</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Moveable object</td>\n",
       "      <td>Troll A platform</td>\n",
       "      <td>Norway</td>\n",
       "      <td>North Sea</td>\n",
       "      <td>472.00</td>\n",
       "      <td>1549.0</td>\n",
       "      <td>1996</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Mast radiator</td>\n",
       "      <td>Lualualei VLF transmitter</td>\n",
       "      <td>United States</td>\n",
       "      <td>Lualualei, Hawaii</td>\n",
       "      <td>458.00</td>\n",
       "      <td>1503.0</td>\n",
       "      <td>1972</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Twin building</td>\n",
       "      <td>Petronas Twin Towers</td>\n",
       "      <td>Malaysia</td>\n",
       "      <td>Kuala Lumpur</td>\n",
       "      <td>452.00</td>\n",
       "      <td>1482.0</td>\n",
       "      <td>1998</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>Steel building[7]</td>\n",
       "      <td>Willis Tower</td>\n",
       "      <td>United States</td>\n",
       "      <td>Chicago, Illinois</td>\n",
       "      <td>442.00</td>\n",
       "      <td>1450.0</td>\n",
       "      <td>1974</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>Chimney</td>\n",
       "      <td>Ekibastuz GRES-2 Power Station</td>\n",
       "      <td>Kazakhstan</td>\n",
       "      <td>Ekibastuz</td>\n",
       "      <td>419.70</td>\n",
       "      <td>1377.0</td>\n",
       "      <td>1987</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>Lattice tower</td>\n",
       "      <td>Kyiv TV Tower</td>\n",
       "      <td>Ukraine</td>\n",
       "      <td>Kyiv</td>\n",
       "      <td>385.00</td>\n",
       "      <td>1263.0</td>\n",
       "      <td>1973</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>Electricity pylon</td>\n",
       "      <td>Jintang-Cezi Overhead Powerline Link</td>\n",
       "      <td>China</td>\n",
       "      <td>Jintang Island</td>\n",
       "      <td>380.00</td>\n",
       "      <td>1247.0</td>\n",
       "      <td>2019</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>Fixed steel structure</td>\n",
       "      <td>Bullwinkle</td>\n",
       "      <td>United States</td>\n",
       "      <td>Gulf of Mexico</td>\n",
       "      <td>529.00</td>\n",
       "      <td>1736.0</td>\n",
       "      <td>1988</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>Partially guyed tower</td>\n",
       "      <td>Gerbrandy Tower</td>\n",
       "      <td>Netherlands</td>\n",
       "      <td>IJsselstein</td>\n",
       "      <td>366.80</td>\n",
       "      <td>1203.0</td>\n",
       "      <td>1961</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>Guyed tubular steel mast</td>\n",
       "      <td>TV Tower Vinnytsia</td>\n",
       "      <td>Ukraine</td>\n",
       "      <td>Vinnytsia</td>\n",
       "      <td>354.00</td>\n",
       "      <td>1161.0</td>\n",
       "      <td>1961</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>Bridge</td>\n",
       "      <td>Millau Viaduct</td>\n",
       "      <td>France</td>\n",
       "      <td>Millau</td>\n",
       "      <td>342.00</td>\n",
       "      <td>1122.0</td>\n",
       "      <td>2004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>Dam</td>\n",
       "      <td>Jinping-I Dam</td>\n",
       "      <td>China</td>\n",
       "      <td>Liangshan</td>\n",
       "      <td>305.00</td>\n",
       "      <td>1001.0</td>\n",
       "      <td>2013</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>Landmark Tower design</td>\n",
       "      <td>Star Tower</td>\n",
       "      <td>United States</td>\n",
       "      <td>Cincinnati</td>\n",
       "      <td>291.00</td>\n",
       "      <td>954.0</td>\n",
       "      <td>1991</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>Elevator test tower</td>\n",
       "      <td>H1 Tower</td>\n",
       "      <td>China</td>\n",
       "      <td>Guangzhou</td>\n",
       "      <td>273.80</td>\n",
       "      <td>898.0</td>\n",
       "      <td>2020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>Wind turbine</td>\n",
       "      <td>Haliade-X Prototype</td>\n",
       "      <td>Netherlands</td>\n",
       "      <td>Rotterdam</td>\n",
       "      <td>270.00</td>\n",
       "      <td>886.0</td>\n",
       "      <td>2019</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>Solar power tower</td>\n",
       "      <td>Mohammed bin Rashid Al Maktoum Solar Park</td>\n",
       "      <td>United Arab Emirates</td>\n",
       "      <td>Saih Al-Dahal</td>\n",
       "      <td>262.00</td>\n",
       "      <td>860.0</td>\n",
       "      <td>2020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>Crane</td>\n",
       "      <td>LR 13000[8]</td>\n",
       "      <td>Germany</td>\n",
       "      <td>NaN</td>\n",
       "      <td>248.00</td>\n",
       "      <td>814.0</td>\n",
       "      <td>2013</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>Jackup rig</td>\n",
       "      <td>Noble Lloyd Noble[9]</td>\n",
       "      <td>Liberia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>214.00</td>\n",
       "      <td>702.0</td>\n",
       "      <td>2016</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>Cooling tower</td>\n",
       "      <td>Kalisindh Thermal Power Station</td>\n",
       "      <td>India</td>\n",
       "      <td>Jhalawar</td>\n",
       "      <td>NaN</td>\n",
       "      <td>663.0</td>\n",
       "      <td>2012</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>Monument</td>\n",
       "      <td>Gateway Arch</td>\n",
       "      <td>United States</td>\n",
       "      <td>St. Louis, Missouri</td>\n",
       "      <td>192.00</td>\n",
       "      <td>630.0</td>\n",
       "      <td>1965</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>Aerial tramway support tower</td>\n",
       "      <td>Tower 2 of Ha Long Queen Cable Car[11]</td>\n",
       "      <td>Vietnam</td>\n",
       "      <td>NaN</td>\n",
       "      <td>189.00</td>\n",
       "      <td>620.0</td>\n",
       "      <td>2016</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>Water tower</td>\n",
       "      <td>Main tower of Kuwait Towers</td>\n",
       "      <td>Kuwait</td>\n",
       "      <td>Kuwait City</td>\n",
       "      <td>187.00</td>\n",
       "      <td>614.0</td>\n",
       "      <td>1979</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>Statue</td>\n",
       "      <td>Statue of Unity</td>\n",
       "      <td>India</td>\n",
       "      <td>Narmada district, Gujarat</td>\n",
       "      <td>NaN</td>\n",
       "      <td>597.0</td>\n",
       "      <td>2018</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>Masonry tower</td>\n",
       "      <td>Anaconda Smelter Stack</td>\n",
       "      <td>United States</td>\n",
       "      <td>Anaconda, Montana</td>\n",
       "      <td>178.30</td>\n",
       "      <td>585.0</td>\n",
       "      <td>1919</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>Inclined structure</td>\n",
       "      <td>Olympic Stadium</td>\n",
       "      <td>Canada</td>\n",
       "      <td>Montreal</td>\n",
       "      <td>175.00</td>\n",
       "      <td>574.0</td>\n",
       "      <td>1976</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>Obelisk</td>\n",
       "      <td>San Jacinto Monument</td>\n",
       "      <td>United States</td>\n",
       "      <td>La Porte, Texas</td>\n",
       "      <td>173.70</td>\n",
       "      <td>570.0</td>\n",
       "      <td>1939</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>Power station building</td>\n",
       "      <td>Niederaussem Power Station</td>\n",
       "      <td>Germany</td>\n",
       "      <td>Bergheim</td>\n",
       "      <td>172.00</td>\n",
       "      <td>564.0</td>\n",
       "      <td>2002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>Flagpole</td>\n",
       "      <td>Jeddah Flagpole</td>\n",
       "      <td>Saudi Arabia</td>\n",
       "      <td>Jeddah</td>\n",
       "      <td>NaN</td>\n",
       "      <td>561.0</td>\n",
       "      <td>2014</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>Ferris wheel</td>\n",
       "      <td>High Roller</td>\n",
       "      <td>United States</td>\n",
       "      <td>Las Vegas</td>\n",
       "      <td>167.60</td>\n",
       "      <td>550.0</td>\n",
       "      <td>2014</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>Masonry building</td>\n",
       "      <td>Mole Antonelliana</td>\n",
       "      <td>Italy</td>\n",
       "      <td>Torino</td>\n",
       "      <td>167.50</td>\n",
       "      <td>550.0</td>\n",
       "      <td>1889</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>Industrial hall</td>\n",
       "      <td>Vehicle Assembly Building</td>\n",
       "      <td>United States</td>\n",
       "      <td>Kennedy Space Center, Florida</td>\n",
       "      <td>160.00</td>\n",
       "      <td>525.0</td>\n",
       "      <td>1966</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>Air traffic control tower</td>\n",
       "      <td>Kuala Lumpur International Airport 2 Control T...</td>\n",
       "      <td>Malaysia</td>\n",
       "      <td>Sepang</td>\n",
       "      <td>141.30</td>\n",
       "      <td>463.6</td>\n",
       "      <td>2013[13]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>Roller coaster</td>\n",
       "      <td>Kingda Ka</td>\n",
       "      <td>United States</td>\n",
       "      <td>Jackson, New Jersey</td>\n",
       "      <td>138.98</td>\n",
       "      <td>456.0</td>\n",
       "      <td>2005</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>Tomb</td>\n",
       "      <td>Great Pyramid of Giza</td>\n",
       "      <td>Egypt</td>\n",
       "      <td>Giza</td>\n",
       "      <td>138.80</td>\n",
       "      <td>455.2</td>\n",
       "      <td>2560 BCE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>Drop tower</td>\n",
       "      <td>Zumanjaro: Drop of Doom</td>\n",
       "      <td>United States</td>\n",
       "      <td>Jackson Township, NJ</td>\n",
       "      <td>139.00</td>\n",
       "      <td>456.0</td>\n",
       "      <td>2014</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>Gantry crane</td>\n",
       "      <td>Kockums Crane</td>\n",
       "      <td>South Korea</td>\n",
       "      <td>Ulsan</td>\n",
       "      <td>NaN</td>\n",
       "      <td>453.0</td>\n",
       "      <td>1974</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>Stupa</td>\n",
       "      <td>Jetavanaramaya</td>\n",
       "      <td>Sri Lanka</td>\n",
       "      <td>Anuradhapura</td>\n",
       "      <td>122.00</td>\n",
       "      <td>400.0</td>\n",
       "      <td>273–301 CE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>Wooden structure</td>\n",
       "      <td>Gliwice Radio Tower</td>\n",
       "      <td>Poland</td>\n",
       "      <td>Gliwice</td>\n",
       "      <td>118.00</td>\n",
       "      <td>387.0</td>\n",
       "      <td>1935</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>Storage silo</td>\n",
       "      <td>Swissmill Tower</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Zurich</td>\n",
       "      <td>118.00</td>\n",
       "      <td>387.0</td>\n",
       "      <td>2016</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>Gasometer</td>\n",
       "      <td>Gasometer Oberhausen</td>\n",
       "      <td>Germany</td>\n",
       "      <td>Oberhausen</td>\n",
       "      <td>117.50</td>\n",
       "      <td>386.0</td>\n",
       "      <td>1929</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>Clock tower</td>\n",
       "      <td>Joseph Chamberlain Memorial Clock Tower</td>\n",
       "      <td>United Kingdom</td>\n",
       "      <td>Birmingham</td>\n",
       "      <td>NaN</td>\n",
       "      <td>328.0</td>\n",
       "      <td>1908</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>Sphere</td>\n",
       "      <td>Avicii Arena</td>\n",
       "      <td>Sweden</td>\n",
       "      <td>Stockholm</td>\n",
       "      <td>85.00</td>\n",
       "      <td>279.0</td>\n",
       "      <td>1989</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>Gopuram</td>\n",
       "      <td>Murudeshwara Temple</td>\n",
       "      <td>India</td>\n",
       "      <td>Murudeshwara</td>\n",
       "      <td>76.00</td>\n",
       "      <td>249.0</td>\n",
       "      <td>2008</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                        Category  \\\n",
       "0                    Building[5]   \n",
       "1                Compliant tower   \n",
       "2       Self-supporting tower[6]   \n",
       "3       Guyed steel lattice mast   \n",
       "4          Hyperboloid structure   \n",
       "5                    Clock tower   \n",
       "7                Moveable object   \n",
       "8                  Mast radiator   \n",
       "9                  Twin building   \n",
       "10             Steel building[7]   \n",
       "11                       Chimney   \n",
       "13                 Lattice tower   \n",
       "14             Electricity pylon   \n",
       "15         Fixed steel structure   \n",
       "16         Partially guyed tower   \n",
       "17      Guyed tubular steel mast   \n",
       "18                        Bridge   \n",
       "20                           Dam   \n",
       "21         Landmark Tower design   \n",
       "22           Elevator test tower   \n",
       "23                  Wind turbine   \n",
       "24             Solar power tower   \n",
       "25                         Crane   \n",
       "26                    Jackup rig   \n",
       "27                 Cooling tower   \n",
       "28                      Monument   \n",
       "29  Aerial tramway support tower   \n",
       "30                   Water tower   \n",
       "31                        Statue   \n",
       "32                 Masonry tower   \n",
       "33            Inclined structure   \n",
       "35                       Obelisk   \n",
       "36        Power station building   \n",
       "37                      Flagpole   \n",
       "38                  Ferris wheel   \n",
       "39              Masonry building   \n",
       "40               Industrial hall   \n",
       "41     Air traffic control tower   \n",
       "42                Roller coaster   \n",
       "43                          Tomb   \n",
       "44                    Drop tower   \n",
       "45                  Gantry crane   \n",
       "46                         Stupa   \n",
       "47              Wooden structure   \n",
       "48                  Storage silo   \n",
       "50                     Gasometer   \n",
       "51                   Clock tower   \n",
       "52                        Sphere   \n",
       "53                       Gopuram   \n",
       "\n",
       "                                            Structure               Country  \\\n",
       "0                                        Burj Khalifa  United Arab Emirates   \n",
       "1                                           Petronius         United States   \n",
       "2                                       Tokyo Skytree                 Japan   \n",
       "3                                        KVLY-TV mast         United States   \n",
       "4                                        Canton Tower                 China   \n",
       "5                                       Abraj Al Bait          Saudi Arabia   \n",
       "7                                    Troll A platform                Norway   \n",
       "8                           Lualualei VLF transmitter         United States   \n",
       "9                                Petronas Twin Towers              Malaysia   \n",
       "10                                       Willis Tower         United States   \n",
       "11                     Ekibastuz GRES-2 Power Station            Kazakhstan   \n",
       "13                                      Kyiv TV Tower               Ukraine   \n",
       "14               Jintang-Cezi Overhead Powerline Link                 China   \n",
       "15                                         Bullwinkle         United States   \n",
       "16                                    Gerbrandy Tower           Netherlands   \n",
       "17                                 TV Tower Vinnytsia               Ukraine   \n",
       "18                                     Millau Viaduct                France   \n",
       "20                                      Jinping-I Dam                 China   \n",
       "21                                         Star Tower         United States   \n",
       "22                                           H1 Tower                 China   \n",
       "23                                Haliade-X Prototype           Netherlands   \n",
       "24          Mohammed bin Rashid Al Maktoum Solar Park  United Arab Emirates   \n",
       "25                                        LR 13000[8]               Germany   \n",
       "26                               Noble Lloyd Noble[9]               Liberia   \n",
       "27                    Kalisindh Thermal Power Station                 India   \n",
       "28                                       Gateway Arch         United States   \n",
       "29             Tower 2 of Ha Long Queen Cable Car[11]               Vietnam   \n",
       "30                        Main tower of Kuwait Towers                Kuwait   \n",
       "31                                    Statue of Unity                 India   \n",
       "32                             Anaconda Smelter Stack         United States   \n",
       "33                                    Olympic Stadium                Canada   \n",
       "35                               San Jacinto Monument         United States   \n",
       "36                         Niederaussem Power Station               Germany   \n",
       "37                                    Jeddah Flagpole          Saudi Arabia   \n",
       "38                                        High Roller         United States   \n",
       "39                                  Mole Antonelliana                 Italy   \n",
       "40                          Vehicle Assembly Building         United States   \n",
       "41  Kuala Lumpur International Airport 2 Control T...              Malaysia   \n",
       "42                                          Kingda Ka         United States   \n",
       "43                              Great Pyramid of Giza                 Egypt   \n",
       "44                            Zumanjaro: Drop of Doom         United States   \n",
       "45                                      Kockums Crane           South Korea   \n",
       "46                                     Jetavanaramaya             Sri Lanka   \n",
       "47                                Gliwice Radio Tower                Poland   \n",
       "48                                    Swissmill Tower           Switzerland   \n",
       "50                               Gasometer Oberhausen               Germany   \n",
       "51            Joseph Chamberlain Memorial Clock Tower        United Kingdom   \n",
       "52                                       Avicii Arena                Sweden   \n",
       "53                                Murudeshwara Temple                 India   \n",
       "\n",
       "                             City  Height (meters)  Height (feet)  Year built  \n",
       "0                           Dubai              NaN         2722.0        2010  \n",
       "1                  Gulf of Mexico           640.00         2100.0        2000  \n",
       "2                           Tokyo           634.00         2080.0        2011  \n",
       "3         Blanchard, North Dakota           629.00         2063.0        1963  \n",
       "4                       Guangzhou           604.00         1982.0        2010  \n",
       "5                           Mecca           601.00         1972.0        2012  \n",
       "7                       North Sea           472.00         1549.0        1996  \n",
       "8               Lualualei, Hawaii           458.00         1503.0        1972  \n",
       "9                    Kuala Lumpur           452.00         1482.0        1998  \n",
       "10              Chicago, Illinois           442.00         1450.0        1974  \n",
       "11                      Ekibastuz           419.70         1377.0        1987  \n",
       "13                           Kyiv           385.00         1263.0        1973  \n",
       "14                 Jintang Island           380.00         1247.0        2019  \n",
       "15                 Gulf of Mexico           529.00         1736.0        1988  \n",
       "16                    IJsselstein           366.80         1203.0        1961  \n",
       "17                      Vinnytsia           354.00         1161.0        1961  \n",
       "18                         Millau           342.00         1122.0        2004  \n",
       "20                      Liangshan           305.00         1001.0        2013  \n",
       "21                     Cincinnati           291.00          954.0        1991  \n",
       "22                      Guangzhou           273.80          898.0        2020  \n",
       "23                      Rotterdam           270.00          886.0        2019  \n",
       "24                  Saih Al-Dahal           262.00          860.0        2020  \n",
       "25                            NaN           248.00          814.0        2013  \n",
       "26                            NaN           214.00          702.0        2016  \n",
       "27                       Jhalawar              NaN          663.0        2012  \n",
       "28            St. Louis, Missouri           192.00          630.0        1965  \n",
       "29                            NaN           189.00          620.0        2016  \n",
       "30                    Kuwait City           187.00          614.0        1979  \n",
       "31      Narmada district, Gujarat              NaN          597.0        2018  \n",
       "32              Anaconda, Montana           178.30          585.0        1919  \n",
       "33                       Montreal           175.00          574.0        1976  \n",
       "35                La Porte, Texas           173.70          570.0        1939  \n",
       "36                       Bergheim           172.00          564.0        2002  \n",
       "37                         Jeddah              NaN          561.0        2014  \n",
       "38                      Las Vegas           167.60          550.0        2014  \n",
       "39                         Torino           167.50          550.0        1889  \n",
       "40  Kennedy Space Center, Florida           160.00          525.0        1966  \n",
       "41                         Sepang           141.30          463.6    2013[13]  \n",
       "42            Jackson, New Jersey           138.98          456.0        2005  \n",
       "43                           Giza           138.80          455.2    2560 BCE  \n",
       "44           Jackson Township, NJ           139.00          456.0        2014  \n",
       "45                          Ulsan              NaN          453.0        1974  \n",
       "46                   Anuradhapura           122.00          400.0  273–301 CE  \n",
       "47                        Gliwice           118.00          387.0        1935  \n",
       "48                         Zurich           118.00          387.0        2016  \n",
       "50                     Oberhausen           117.50          386.0        1929  \n",
       "51                     Birmingham              NaN          328.0        1908  \n",
       "52                      Stockholm            85.00          279.0        1989  \n",
       "53                   Murudeshwara            76.00          249.0        2008  "
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tallest=tallest.dropna(thresh=4) \n",
    "tallest"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "24b5f2e6",
   "metadata": {},
   "source": [
    "(f) For missing data in column Height (meters):\n",
    "    \n",
    "    (i) Get the row index of all missing values in Height (meters) and save in a list named \n",
    "    missing_Height"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "16e2a20d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 27, 31, 37, 45, 51]"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#index value of missing values in 'Height (meters)'\n",
    "missing_Height = tallest[tallest['Height (meters)'].isnull()].index.tolist()\n",
    "missing_Height"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e2b9e3c6",
   "metadata": {},
   "source": [
    "    (ii) Fill in the missing value with conversion of feet value in Height (feet) which having the \n",
    "    index in missing_Height. The conversion rate is 1 feet = 0.3 meters."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "c4d581be",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0     2722.0\n",
      "27     663.0\n",
      "31     597.0\n",
      "37     561.0\n",
      "45     453.0\n",
      "51     328.0\n",
      "Name: Height (feet), dtype: float64\n",
      "\n",
      "[816.6, 198.9, 179.1, 168.29999999999998, 135.9, 98.39999999999999]\n",
      "\n",
      "['816.60', '198.90', '179.10', '168.30', '135.90', '98.40']\n"
     ]
    }
   ],
   "source": [
    "tallest2 = tallest.query('index in @missing_Height')['Height (feet)']\n",
    "print(tallest2)\n",
    "print()\n",
    "\n",
    "#conversion rate\n",
    "rate = [item * 0.3 for item in tallest2]\n",
    "print(rate)\n",
    "print()\n",
    "\n",
    "#2 decimal place\n",
    "rate2 = [ '%.2f' % elem for elem in rate ]\n",
    "print(rate2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "83b75278",
   "metadata": {},
   "outputs": [
    {
     "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>Category</th>\n",
       "      <th>Structure</th>\n",
       "      <th>Country</th>\n",
       "      <th>City</th>\n",
       "      <th>Height (meters)</th>\n",
       "      <th>Height (feet)</th>\n",
       "      <th>Year built</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Building[5]</td>\n",
       "      <td>Burj Khalifa</td>\n",
       "      <td>United Arab Emirates</td>\n",
       "      <td>Dubai</td>\n",
       "      <td>816.60</td>\n",
       "      <td>2722.0</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Compliant tower</td>\n",
       "      <td>Petronius</td>\n",
       "      <td>United States</td>\n",
       "      <td>Gulf of Mexico</td>\n",
       "      <td>640.00</td>\n",
       "      <td>2100.0</td>\n",
       "      <td>2000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Self-supporting tower[6]</td>\n",
       "      <td>Tokyo Skytree</td>\n",
       "      <td>Japan</td>\n",
       "      <td>Tokyo</td>\n",
       "      <td>634.00</td>\n",
       "      <td>2080.0</td>\n",
       "      <td>2011</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Guyed steel lattice mast</td>\n",
       "      <td>KVLY-TV mast</td>\n",
       "      <td>United States</td>\n",
       "      <td>Blanchard, North Dakota</td>\n",
       "      <td>629.00</td>\n",
       "      <td>2063.0</td>\n",
       "      <td>1963</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Hyperboloid structure</td>\n",
       "      <td>Canton Tower</td>\n",
       "      <td>China</td>\n",
       "      <td>Guangzhou</td>\n",
       "      <td>604.00</td>\n",
       "      <td>1982.0</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Clock tower</td>\n",
       "      <td>Abraj Al Bait</td>\n",
       "      <td>Saudi Arabia</td>\n",
       "      <td>Mecca</td>\n",
       "      <td>601.00</td>\n",
       "      <td>1972.0</td>\n",
       "      <td>2012</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Moveable object</td>\n",
       "      <td>Troll A platform</td>\n",
       "      <td>Norway</td>\n",
       "      <td>North Sea</td>\n",
       "      <td>472.00</td>\n",
       "      <td>1549.0</td>\n",
       "      <td>1996</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Mast radiator</td>\n",
       "      <td>Lualualei VLF transmitter</td>\n",
       "      <td>United States</td>\n",
       "      <td>Lualualei, Hawaii</td>\n",
       "      <td>458.00</td>\n",
       "      <td>1503.0</td>\n",
       "      <td>1972</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Twin building</td>\n",
       "      <td>Petronas Twin Towers</td>\n",
       "      <td>Malaysia</td>\n",
       "      <td>Kuala Lumpur</td>\n",
       "      <td>452.00</td>\n",
       "      <td>1482.0</td>\n",
       "      <td>1998</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>Steel building[7]</td>\n",
       "      <td>Willis Tower</td>\n",
       "      <td>United States</td>\n",
       "      <td>Chicago, Illinois</td>\n",
       "      <td>442.00</td>\n",
       "      <td>1450.0</td>\n",
       "      <td>1974</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>Chimney</td>\n",
       "      <td>Ekibastuz GRES-2 Power Station</td>\n",
       "      <td>Kazakhstan</td>\n",
       "      <td>Ekibastuz</td>\n",
       "      <td>419.70</td>\n",
       "      <td>1377.0</td>\n",
       "      <td>1987</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>Lattice tower</td>\n",
       "      <td>Kyiv TV Tower</td>\n",
       "      <td>Ukraine</td>\n",
       "      <td>Kyiv</td>\n",
       "      <td>385.00</td>\n",
       "      <td>1263.0</td>\n",
       "      <td>1973</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>Electricity pylon</td>\n",
       "      <td>Jintang-Cezi Overhead Powerline Link</td>\n",
       "      <td>China</td>\n",
       "      <td>Jintang Island</td>\n",
       "      <td>380.00</td>\n",
       "      <td>1247.0</td>\n",
       "      <td>2019</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>Fixed steel structure</td>\n",
       "      <td>Bullwinkle</td>\n",
       "      <td>United States</td>\n",
       "      <td>Gulf of Mexico</td>\n",
       "      <td>529.00</td>\n",
       "      <td>1736.0</td>\n",
       "      <td>1988</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>Partially guyed tower</td>\n",
       "      <td>Gerbrandy Tower</td>\n",
       "      <td>Netherlands</td>\n",
       "      <td>IJsselstein</td>\n",
       "      <td>366.80</td>\n",
       "      <td>1203.0</td>\n",
       "      <td>1961</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>Guyed tubular steel mast</td>\n",
       "      <td>TV Tower Vinnytsia</td>\n",
       "      <td>Ukraine</td>\n",
       "      <td>Vinnytsia</td>\n",
       "      <td>354.00</td>\n",
       "      <td>1161.0</td>\n",
       "      <td>1961</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>Bridge</td>\n",
       "      <td>Millau Viaduct</td>\n",
       "      <td>France</td>\n",
       "      <td>Millau</td>\n",
       "      <td>342.00</td>\n",
       "      <td>1122.0</td>\n",
       "      <td>2004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>Dam</td>\n",
       "      <td>Jinping-I Dam</td>\n",
       "      <td>China</td>\n",
       "      <td>Liangshan</td>\n",
       "      <td>305.00</td>\n",
       "      <td>1001.0</td>\n",
       "      <td>2013</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>Landmark Tower design</td>\n",
       "      <td>Star Tower</td>\n",
       "      <td>United States</td>\n",
       "      <td>Cincinnati</td>\n",
       "      <td>291.00</td>\n",
       "      <td>954.0</td>\n",
       "      <td>1991</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>Elevator test tower</td>\n",
       "      <td>H1 Tower</td>\n",
       "      <td>China</td>\n",
       "      <td>Guangzhou</td>\n",
       "      <td>273.80</td>\n",
       "      <td>898.0</td>\n",
       "      <td>2020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>Wind turbine</td>\n",
       "      <td>Haliade-X Prototype</td>\n",
       "      <td>Netherlands</td>\n",
       "      <td>Rotterdam</td>\n",
       "      <td>270.00</td>\n",
       "      <td>886.0</td>\n",
       "      <td>2019</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>Solar power tower</td>\n",
       "      <td>Mohammed bin Rashid Al Maktoum Solar Park</td>\n",
       "      <td>United Arab Emirates</td>\n",
       "      <td>Saih Al-Dahal</td>\n",
       "      <td>262.00</td>\n",
       "      <td>860.0</td>\n",
       "      <td>2020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>Crane</td>\n",
       "      <td>LR 13000[8]</td>\n",
       "      <td>Germany</td>\n",
       "      <td>NaN</td>\n",
       "      <td>248.00</td>\n",
       "      <td>814.0</td>\n",
       "      <td>2013</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>Jackup rig</td>\n",
       "      <td>Noble Lloyd Noble[9]</td>\n",
       "      <td>Liberia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>214.00</td>\n",
       "      <td>702.0</td>\n",
       "      <td>2016</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>Cooling tower</td>\n",
       "      <td>Kalisindh Thermal Power Station</td>\n",
       "      <td>India</td>\n",
       "      <td>Jhalawar</td>\n",
       "      <td>198.90</td>\n",
       "      <td>663.0</td>\n",
       "      <td>2012</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>Monument</td>\n",
       "      <td>Gateway Arch</td>\n",
       "      <td>United States</td>\n",
       "      <td>St. Louis, Missouri</td>\n",
       "      <td>192.00</td>\n",
       "      <td>630.0</td>\n",
       "      <td>1965</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>Aerial tramway support tower</td>\n",
       "      <td>Tower 2 of Ha Long Queen Cable Car[11]</td>\n",
       "      <td>Vietnam</td>\n",
       "      <td>NaN</td>\n",
       "      <td>189.00</td>\n",
       "      <td>620.0</td>\n",
       "      <td>2016</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>Water tower</td>\n",
       "      <td>Main tower of Kuwait Towers</td>\n",
       "      <td>Kuwait</td>\n",
       "      <td>Kuwait City</td>\n",
       "      <td>187.00</td>\n",
       "      <td>614.0</td>\n",
       "      <td>1979</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>Statue</td>\n",
       "      <td>Statue of Unity</td>\n",
       "      <td>India</td>\n",
       "      <td>Narmada district, Gujarat</td>\n",
       "      <td>179.10</td>\n",
       "      <td>597.0</td>\n",
       "      <td>2018</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>Masonry tower</td>\n",
       "      <td>Anaconda Smelter Stack</td>\n",
       "      <td>United States</td>\n",
       "      <td>Anaconda, Montana</td>\n",
       "      <td>178.30</td>\n",
       "      <td>585.0</td>\n",
       "      <td>1919</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>Inclined structure</td>\n",
       "      <td>Olympic Stadium</td>\n",
       "      <td>Canada</td>\n",
       "      <td>Montreal</td>\n",
       "      <td>175.00</td>\n",
       "      <td>574.0</td>\n",
       "      <td>1976</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>Obelisk</td>\n",
       "      <td>San Jacinto Monument</td>\n",
       "      <td>United States</td>\n",
       "      <td>La Porte, Texas</td>\n",
       "      <td>173.70</td>\n",
       "      <td>570.0</td>\n",
       "      <td>1939</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>Power station building</td>\n",
       "      <td>Niederaussem Power Station</td>\n",
       "      <td>Germany</td>\n",
       "      <td>Bergheim</td>\n",
       "      <td>172.00</td>\n",
       "      <td>564.0</td>\n",
       "      <td>2002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>Flagpole</td>\n",
       "      <td>Jeddah Flagpole</td>\n",
       "      <td>Saudi Arabia</td>\n",
       "      <td>Jeddah</td>\n",
       "      <td>168.30</td>\n",
       "      <td>561.0</td>\n",
       "      <td>2014</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>Ferris wheel</td>\n",
       "      <td>High Roller</td>\n",
       "      <td>United States</td>\n",
       "      <td>Las Vegas</td>\n",
       "      <td>167.60</td>\n",
       "      <td>550.0</td>\n",
       "      <td>2014</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>Masonry building</td>\n",
       "      <td>Mole Antonelliana</td>\n",
       "      <td>Italy</td>\n",
       "      <td>Torino</td>\n",
       "      <td>167.50</td>\n",
       "      <td>550.0</td>\n",
       "      <td>1889</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>Industrial hall</td>\n",
       "      <td>Vehicle Assembly Building</td>\n",
       "      <td>United States</td>\n",
       "      <td>Kennedy Space Center, Florida</td>\n",
       "      <td>160.00</td>\n",
       "      <td>525.0</td>\n",
       "      <td>1966</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>Air traffic control tower</td>\n",
       "      <td>Kuala Lumpur International Airport 2 Control T...</td>\n",
       "      <td>Malaysia</td>\n",
       "      <td>Sepang</td>\n",
       "      <td>141.30</td>\n",
       "      <td>463.6</td>\n",
       "      <td>2013[13]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>Roller coaster</td>\n",
       "      <td>Kingda Ka</td>\n",
       "      <td>United States</td>\n",
       "      <td>Jackson, New Jersey</td>\n",
       "      <td>138.98</td>\n",
       "      <td>456.0</td>\n",
       "      <td>2005</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>Tomb</td>\n",
       "      <td>Great Pyramid of Giza</td>\n",
       "      <td>Egypt</td>\n",
       "      <td>Giza</td>\n",
       "      <td>138.80</td>\n",
       "      <td>455.2</td>\n",
       "      <td>2560 BCE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>Drop tower</td>\n",
       "      <td>Zumanjaro: Drop of Doom</td>\n",
       "      <td>United States</td>\n",
       "      <td>Jackson Township, NJ</td>\n",
       "      <td>139.00</td>\n",
       "      <td>456.0</td>\n",
       "      <td>2014</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>Gantry crane</td>\n",
       "      <td>Kockums Crane</td>\n",
       "      <td>South Korea</td>\n",
       "      <td>Ulsan</td>\n",
       "      <td>135.90</td>\n",
       "      <td>453.0</td>\n",
       "      <td>1974</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>Stupa</td>\n",
       "      <td>Jetavanaramaya</td>\n",
       "      <td>Sri Lanka</td>\n",
       "      <td>Anuradhapura</td>\n",
       "      <td>122.00</td>\n",
       "      <td>400.0</td>\n",
       "      <td>273–301 CE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>Wooden structure</td>\n",
       "      <td>Gliwice Radio Tower</td>\n",
       "      <td>Poland</td>\n",
       "      <td>Gliwice</td>\n",
       "      <td>118.00</td>\n",
       "      <td>387.0</td>\n",
       "      <td>1935</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>Storage silo</td>\n",
       "      <td>Swissmill Tower</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Zurich</td>\n",
       "      <td>118.00</td>\n",
       "      <td>387.0</td>\n",
       "      <td>2016</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>Gasometer</td>\n",
       "      <td>Gasometer Oberhausen</td>\n",
       "      <td>Germany</td>\n",
       "      <td>Oberhausen</td>\n",
       "      <td>117.50</td>\n",
       "      <td>386.0</td>\n",
       "      <td>1929</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>Clock tower</td>\n",
       "      <td>Joseph Chamberlain Memorial Clock Tower</td>\n",
       "      <td>United Kingdom</td>\n",
       "      <td>Birmingham</td>\n",
       "      <td>98.40</td>\n",
       "      <td>328.0</td>\n",
       "      <td>1908</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>Sphere</td>\n",
       "      <td>Avicii Arena</td>\n",
       "      <td>Sweden</td>\n",
       "      <td>Stockholm</td>\n",
       "      <td>85.00</td>\n",
       "      <td>279.0</td>\n",
       "      <td>1989</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>Gopuram</td>\n",
       "      <td>Murudeshwara Temple</td>\n",
       "      <td>India</td>\n",
       "      <td>Murudeshwara</td>\n",
       "      <td>76.00</td>\n",
       "      <td>249.0</td>\n",
       "      <td>2008</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                        Category  \\\n",
       "0                    Building[5]   \n",
       "1                Compliant tower   \n",
       "2       Self-supporting tower[6]   \n",
       "3       Guyed steel lattice mast   \n",
       "4          Hyperboloid structure   \n",
       "5                    Clock tower   \n",
       "7                Moveable object   \n",
       "8                  Mast radiator   \n",
       "9                  Twin building   \n",
       "10             Steel building[7]   \n",
       "11                       Chimney   \n",
       "13                 Lattice tower   \n",
       "14             Electricity pylon   \n",
       "15         Fixed steel structure   \n",
       "16         Partially guyed tower   \n",
       "17      Guyed tubular steel mast   \n",
       "18                        Bridge   \n",
       "20                           Dam   \n",
       "21         Landmark Tower design   \n",
       "22           Elevator test tower   \n",
       "23                  Wind turbine   \n",
       "24             Solar power tower   \n",
       "25                         Crane   \n",
       "26                    Jackup rig   \n",
       "27                 Cooling tower   \n",
       "28                      Monument   \n",
       "29  Aerial tramway support tower   \n",
       "30                   Water tower   \n",
       "31                        Statue   \n",
       "32                 Masonry tower   \n",
       "33            Inclined structure   \n",
       "35                       Obelisk   \n",
       "36        Power station building   \n",
       "37                      Flagpole   \n",
       "38                  Ferris wheel   \n",
       "39              Masonry building   \n",
       "40               Industrial hall   \n",
       "41     Air traffic control tower   \n",
       "42                Roller coaster   \n",
       "43                          Tomb   \n",
       "44                    Drop tower   \n",
       "45                  Gantry crane   \n",
       "46                         Stupa   \n",
       "47              Wooden structure   \n",
       "48                  Storage silo   \n",
       "50                     Gasometer   \n",
       "51                   Clock tower   \n",
       "52                        Sphere   \n",
       "53                       Gopuram   \n",
       "\n",
       "                                            Structure               Country  \\\n",
       "0                                        Burj Khalifa  United Arab Emirates   \n",
       "1                                           Petronius         United States   \n",
       "2                                       Tokyo Skytree                 Japan   \n",
       "3                                        KVLY-TV mast         United States   \n",
       "4                                        Canton Tower                 China   \n",
       "5                                       Abraj Al Bait          Saudi Arabia   \n",
       "7                                    Troll A platform                Norway   \n",
       "8                           Lualualei VLF transmitter         United States   \n",
       "9                                Petronas Twin Towers              Malaysia   \n",
       "10                                       Willis Tower         United States   \n",
       "11                     Ekibastuz GRES-2 Power Station            Kazakhstan   \n",
       "13                                      Kyiv TV Tower               Ukraine   \n",
       "14               Jintang-Cezi Overhead Powerline Link                 China   \n",
       "15                                         Bullwinkle         United States   \n",
       "16                                    Gerbrandy Tower           Netherlands   \n",
       "17                                 TV Tower Vinnytsia               Ukraine   \n",
       "18                                     Millau Viaduct                France   \n",
       "20                                      Jinping-I Dam                 China   \n",
       "21                                         Star Tower         United States   \n",
       "22                                           H1 Tower                 China   \n",
       "23                                Haliade-X Prototype           Netherlands   \n",
       "24          Mohammed bin Rashid Al Maktoum Solar Park  United Arab Emirates   \n",
       "25                                        LR 13000[8]               Germany   \n",
       "26                               Noble Lloyd Noble[9]               Liberia   \n",
       "27                    Kalisindh Thermal Power Station                 India   \n",
       "28                                       Gateway Arch         United States   \n",
       "29             Tower 2 of Ha Long Queen Cable Car[11]               Vietnam   \n",
       "30                        Main tower of Kuwait Towers                Kuwait   \n",
       "31                                    Statue of Unity                 India   \n",
       "32                             Anaconda Smelter Stack         United States   \n",
       "33                                    Olympic Stadium                Canada   \n",
       "35                               San Jacinto Monument         United States   \n",
       "36                         Niederaussem Power Station               Germany   \n",
       "37                                    Jeddah Flagpole          Saudi Arabia   \n",
       "38                                        High Roller         United States   \n",
       "39                                  Mole Antonelliana                 Italy   \n",
       "40                          Vehicle Assembly Building         United States   \n",
       "41  Kuala Lumpur International Airport 2 Control T...              Malaysia   \n",
       "42                                          Kingda Ka         United States   \n",
       "43                              Great Pyramid of Giza                 Egypt   \n",
       "44                            Zumanjaro: Drop of Doom         United States   \n",
       "45                                      Kockums Crane           South Korea   \n",
       "46                                     Jetavanaramaya             Sri Lanka   \n",
       "47                                Gliwice Radio Tower                Poland   \n",
       "48                                    Swissmill Tower           Switzerland   \n",
       "50                               Gasometer Oberhausen               Germany   \n",
       "51            Joseph Chamberlain Memorial Clock Tower        United Kingdom   \n",
       "52                                       Avicii Arena                Sweden   \n",
       "53                                Murudeshwara Temple                 India   \n",
       "\n",
       "                             City  Height (meters)  Height (feet)  Year built  \n",
       "0                           Dubai           816.60         2722.0        2010  \n",
       "1                  Gulf of Mexico           640.00         2100.0        2000  \n",
       "2                           Tokyo           634.00         2080.0        2011  \n",
       "3         Blanchard, North Dakota           629.00         2063.0        1963  \n",
       "4                       Guangzhou           604.00         1982.0        2010  \n",
       "5                           Mecca           601.00         1972.0        2012  \n",
       "7                       North Sea           472.00         1549.0        1996  \n",
       "8               Lualualei, Hawaii           458.00         1503.0        1972  \n",
       "9                    Kuala Lumpur           452.00         1482.0        1998  \n",
       "10              Chicago, Illinois           442.00         1450.0        1974  \n",
       "11                      Ekibastuz           419.70         1377.0        1987  \n",
       "13                           Kyiv           385.00         1263.0        1973  \n",
       "14                 Jintang Island           380.00         1247.0        2019  \n",
       "15                 Gulf of Mexico           529.00         1736.0        1988  \n",
       "16                    IJsselstein           366.80         1203.0        1961  \n",
       "17                      Vinnytsia           354.00         1161.0        1961  \n",
       "18                         Millau           342.00         1122.0        2004  \n",
       "20                      Liangshan           305.00         1001.0        2013  \n",
       "21                     Cincinnati           291.00          954.0        1991  \n",
       "22                      Guangzhou           273.80          898.0        2020  \n",
       "23                      Rotterdam           270.00          886.0        2019  \n",
       "24                  Saih Al-Dahal           262.00          860.0        2020  \n",
       "25                            NaN           248.00          814.0        2013  \n",
       "26                            NaN           214.00          702.0        2016  \n",
       "27                       Jhalawar           198.90          663.0        2012  \n",
       "28            St. Louis, Missouri           192.00          630.0        1965  \n",
       "29                            NaN           189.00          620.0        2016  \n",
       "30                    Kuwait City           187.00          614.0        1979  \n",
       "31      Narmada district, Gujarat           179.10          597.0        2018  \n",
       "32              Anaconda, Montana           178.30          585.0        1919  \n",
       "33                       Montreal           175.00          574.0        1976  \n",
       "35                La Porte, Texas           173.70          570.0        1939  \n",
       "36                       Bergheim           172.00          564.0        2002  \n",
       "37                         Jeddah           168.30          561.0        2014  \n",
       "38                      Las Vegas           167.60          550.0        2014  \n",
       "39                         Torino           167.50          550.0        1889  \n",
       "40  Kennedy Space Center, Florida           160.00          525.0        1966  \n",
       "41                         Sepang           141.30          463.6    2013[13]  \n",
       "42            Jackson, New Jersey           138.98          456.0        2005  \n",
       "43                           Giza           138.80          455.2    2560 BCE  \n",
       "44           Jackson Township, NJ           139.00          456.0        2014  \n",
       "45                          Ulsan           135.90          453.0        1974  \n",
       "46                   Anuradhapura           122.00          400.0  273–301 CE  \n",
       "47                        Gliwice           118.00          387.0        1935  \n",
       "48                         Zurich           118.00          387.0        2016  \n",
       "50                     Oberhausen           117.50          386.0        1929  \n",
       "51                     Birmingham            98.40          328.0        1908  \n",
       "52                      Stockholm            85.00          279.0        1989  \n",
       "53                   Murudeshwara            76.00          249.0        2008  "
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#fill in missing value in 'Height (meters)' with the conversion rate of 'Height (feet)'\n",
    "tallest['Height (meters)'] = tallest.apply(\n",
    "    lambda row: row['Height (feet)']*0.3 if np.isnan(row['Height (meters)']) else row['Height (meters)'],\n",
    "    axis=1\n",
    ")\n",
    "\n",
    "tallest"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "17c84c9a",
   "metadata": {},
   "source": [
    "(g) For missing data in column City:\n",
    "\n",
    "    (i) Get the row index of all missing values in City and save in a list named missing_City"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "e3f85db2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[25, 26, 29]"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#list index of missing value\n",
    "missing_City = tallest[tallest['City'].isnull()].index.tolist()\n",
    "missing_City"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "08ed30b7",
   "metadata": {},
   "source": [
    "    (ii) Fill in the missing value with the value in Country which having the index in \n",
    "    missing_City"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "674ed45e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "25    Germany\n",
      "26    Liberia\n",
      "29    Vietnam\n",
      "Name: Country, dtype: object\n",
      "\n"
     ]
    }
   ],
   "source": [
    "city2 = tallest.query('index in @missing_City')['Country']\n",
    "print(city2)\n",
    "print()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "d26a6f94",
   "metadata": {},
   "outputs": [
    {
     "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>Category</th>\n",
       "      <th>Structure</th>\n",
       "      <th>Country</th>\n",
       "      <th>City</th>\n",
       "      <th>Height (meters)</th>\n",
       "      <th>Height (feet)</th>\n",
       "      <th>Year built</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Building[5]</td>\n",
       "      <td>Burj Khalifa</td>\n",
       "      <td>United Arab Emirates</td>\n",
       "      <td>Dubai</td>\n",
       "      <td>816.60</td>\n",
       "      <td>2722.0</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Compliant tower</td>\n",
       "      <td>Petronius</td>\n",
       "      <td>United States</td>\n",
       "      <td>Gulf of Mexico</td>\n",
       "      <td>640.00</td>\n",
       "      <td>2100.0</td>\n",
       "      <td>2000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Self-supporting tower[6]</td>\n",
       "      <td>Tokyo Skytree</td>\n",
       "      <td>Japan</td>\n",
       "      <td>Tokyo</td>\n",
       "      <td>634.00</td>\n",
       "      <td>2080.0</td>\n",
       "      <td>2011</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Guyed steel lattice mast</td>\n",
       "      <td>KVLY-TV mast</td>\n",
       "      <td>United States</td>\n",
       "      <td>Blanchard, North Dakota</td>\n",
       "      <td>629.00</td>\n",
       "      <td>2063.0</td>\n",
       "      <td>1963</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Hyperboloid structure</td>\n",
       "      <td>Canton Tower</td>\n",
       "      <td>China</td>\n",
       "      <td>Guangzhou</td>\n",
       "      <td>604.00</td>\n",
       "      <td>1982.0</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Clock tower</td>\n",
       "      <td>Abraj Al Bait</td>\n",
       "      <td>Saudi Arabia</td>\n",
       "      <td>Mecca</td>\n",
       "      <td>601.00</td>\n",
       "      <td>1972.0</td>\n",
       "      <td>2012</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Moveable object</td>\n",
       "      <td>Troll A platform</td>\n",
       "      <td>Norway</td>\n",
       "      <td>North Sea</td>\n",
       "      <td>472.00</td>\n",
       "      <td>1549.0</td>\n",
       "      <td>1996</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Mast radiator</td>\n",
       "      <td>Lualualei VLF transmitter</td>\n",
       "      <td>United States</td>\n",
       "      <td>Lualualei, Hawaii</td>\n",
       "      <td>458.00</td>\n",
       "      <td>1503.0</td>\n",
       "      <td>1972</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Twin building</td>\n",
       "      <td>Petronas Twin Towers</td>\n",
       "      <td>Malaysia</td>\n",
       "      <td>Kuala Lumpur</td>\n",
       "      <td>452.00</td>\n",
       "      <td>1482.0</td>\n",
       "      <td>1998</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>Steel building[7]</td>\n",
       "      <td>Willis Tower</td>\n",
       "      <td>United States</td>\n",
       "      <td>Chicago, Illinois</td>\n",
       "      <td>442.00</td>\n",
       "      <td>1450.0</td>\n",
       "      <td>1974</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>Chimney</td>\n",
       "      <td>Ekibastuz GRES-2 Power Station</td>\n",
       "      <td>Kazakhstan</td>\n",
       "      <td>Ekibastuz</td>\n",
       "      <td>419.70</td>\n",
       "      <td>1377.0</td>\n",
       "      <td>1987</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>Lattice tower</td>\n",
       "      <td>Kyiv TV Tower</td>\n",
       "      <td>Ukraine</td>\n",
       "      <td>Kyiv</td>\n",
       "      <td>385.00</td>\n",
       "      <td>1263.0</td>\n",
       "      <td>1973</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>Electricity pylon</td>\n",
       "      <td>Jintang-Cezi Overhead Powerline Link</td>\n",
       "      <td>China</td>\n",
       "      <td>Jintang Island</td>\n",
       "      <td>380.00</td>\n",
       "      <td>1247.0</td>\n",
       "      <td>2019</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>Fixed steel structure</td>\n",
       "      <td>Bullwinkle</td>\n",
       "      <td>United States</td>\n",
       "      <td>Gulf of Mexico</td>\n",
       "      <td>529.00</td>\n",
       "      <td>1736.0</td>\n",
       "      <td>1988</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>Partially guyed tower</td>\n",
       "      <td>Gerbrandy Tower</td>\n",
       "      <td>Netherlands</td>\n",
       "      <td>IJsselstein</td>\n",
       "      <td>366.80</td>\n",
       "      <td>1203.0</td>\n",
       "      <td>1961</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>Guyed tubular steel mast</td>\n",
       "      <td>TV Tower Vinnytsia</td>\n",
       "      <td>Ukraine</td>\n",
       "      <td>Vinnytsia</td>\n",
       "      <td>354.00</td>\n",
       "      <td>1161.0</td>\n",
       "      <td>1961</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>Bridge</td>\n",
       "      <td>Millau Viaduct</td>\n",
       "      <td>France</td>\n",
       "      <td>Millau</td>\n",
       "      <td>342.00</td>\n",
       "      <td>1122.0</td>\n",
       "      <td>2004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>Dam</td>\n",
       "      <td>Jinping-I Dam</td>\n",
       "      <td>China</td>\n",
       "      <td>Liangshan</td>\n",
       "      <td>305.00</td>\n",
       "      <td>1001.0</td>\n",
       "      <td>2013</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>Landmark Tower design</td>\n",
       "      <td>Star Tower</td>\n",
       "      <td>United States</td>\n",
       "      <td>Cincinnati</td>\n",
       "      <td>291.00</td>\n",
       "      <td>954.0</td>\n",
       "      <td>1991</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>Elevator test tower</td>\n",
       "      <td>H1 Tower</td>\n",
       "      <td>China</td>\n",
       "      <td>Guangzhou</td>\n",
       "      <td>273.80</td>\n",
       "      <td>898.0</td>\n",
       "      <td>2020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>Wind turbine</td>\n",
       "      <td>Haliade-X Prototype</td>\n",
       "      <td>Netherlands</td>\n",
       "      <td>Rotterdam</td>\n",
       "      <td>270.00</td>\n",
       "      <td>886.0</td>\n",
       "      <td>2019</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>Solar power tower</td>\n",
       "      <td>Mohammed bin Rashid Al Maktoum Solar Park</td>\n",
       "      <td>United Arab Emirates</td>\n",
       "      <td>Saih Al-Dahal</td>\n",
       "      <td>262.00</td>\n",
       "      <td>860.0</td>\n",
       "      <td>2020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>Crane</td>\n",
       "      <td>LR 13000[8]</td>\n",
       "      <td>Germany</td>\n",
       "      <td>Germany</td>\n",
       "      <td>248.00</td>\n",
       "      <td>814.0</td>\n",
       "      <td>2013</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>Jackup rig</td>\n",
       "      <td>Noble Lloyd Noble[9]</td>\n",
       "      <td>Liberia</td>\n",
       "      <td>Liberia</td>\n",
       "      <td>214.00</td>\n",
       "      <td>702.0</td>\n",
       "      <td>2016</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>Cooling tower</td>\n",
       "      <td>Kalisindh Thermal Power Station</td>\n",
       "      <td>India</td>\n",
       "      <td>Jhalawar</td>\n",
       "      <td>198.90</td>\n",
       "      <td>663.0</td>\n",
       "      <td>2012</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>Monument</td>\n",
       "      <td>Gateway Arch</td>\n",
       "      <td>United States</td>\n",
       "      <td>St. Louis, Missouri</td>\n",
       "      <td>192.00</td>\n",
       "      <td>630.0</td>\n",
       "      <td>1965</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>Aerial tramway support tower</td>\n",
       "      <td>Tower 2 of Ha Long Queen Cable Car[11]</td>\n",
       "      <td>Vietnam</td>\n",
       "      <td>Vietnam</td>\n",
       "      <td>189.00</td>\n",
       "      <td>620.0</td>\n",
       "      <td>2016</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>Water tower</td>\n",
       "      <td>Main tower of Kuwait Towers</td>\n",
       "      <td>Kuwait</td>\n",
       "      <td>Kuwait City</td>\n",
       "      <td>187.00</td>\n",
       "      <td>614.0</td>\n",
       "      <td>1979</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>Statue</td>\n",
       "      <td>Statue of Unity</td>\n",
       "      <td>India</td>\n",
       "      <td>Narmada district, Gujarat</td>\n",
       "      <td>179.10</td>\n",
       "      <td>597.0</td>\n",
       "      <td>2018</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>Masonry tower</td>\n",
       "      <td>Anaconda Smelter Stack</td>\n",
       "      <td>United States</td>\n",
       "      <td>Anaconda, Montana</td>\n",
       "      <td>178.30</td>\n",
       "      <td>585.0</td>\n",
       "      <td>1919</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>Inclined structure</td>\n",
       "      <td>Olympic Stadium</td>\n",
       "      <td>Canada</td>\n",
       "      <td>Montreal</td>\n",
       "      <td>175.00</td>\n",
       "      <td>574.0</td>\n",
       "      <td>1976</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>Obelisk</td>\n",
       "      <td>San Jacinto Monument</td>\n",
       "      <td>United States</td>\n",
       "      <td>La Porte, Texas</td>\n",
       "      <td>173.70</td>\n",
       "      <td>570.0</td>\n",
       "      <td>1939</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>Power station building</td>\n",
       "      <td>Niederaussem Power Station</td>\n",
       "      <td>Germany</td>\n",
       "      <td>Bergheim</td>\n",
       "      <td>172.00</td>\n",
       "      <td>564.0</td>\n",
       "      <td>2002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>Flagpole</td>\n",
       "      <td>Jeddah Flagpole</td>\n",
       "      <td>Saudi Arabia</td>\n",
       "      <td>Jeddah</td>\n",
       "      <td>168.30</td>\n",
       "      <td>561.0</td>\n",
       "      <td>2014</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>Ferris wheel</td>\n",
       "      <td>High Roller</td>\n",
       "      <td>United States</td>\n",
       "      <td>Las Vegas</td>\n",
       "      <td>167.60</td>\n",
       "      <td>550.0</td>\n",
       "      <td>2014</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>Masonry building</td>\n",
       "      <td>Mole Antonelliana</td>\n",
       "      <td>Italy</td>\n",
       "      <td>Torino</td>\n",
       "      <td>167.50</td>\n",
       "      <td>550.0</td>\n",
       "      <td>1889</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>Industrial hall</td>\n",
       "      <td>Vehicle Assembly Building</td>\n",
       "      <td>United States</td>\n",
       "      <td>Kennedy Space Center, Florida</td>\n",
       "      <td>160.00</td>\n",
       "      <td>525.0</td>\n",
       "      <td>1966</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>Air traffic control tower</td>\n",
       "      <td>Kuala Lumpur International Airport 2 Control T...</td>\n",
       "      <td>Malaysia</td>\n",
       "      <td>Sepang</td>\n",
       "      <td>141.30</td>\n",
       "      <td>463.6</td>\n",
       "      <td>2013[13]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>Roller coaster</td>\n",
       "      <td>Kingda Ka</td>\n",
       "      <td>United States</td>\n",
       "      <td>Jackson, New Jersey</td>\n",
       "      <td>138.98</td>\n",
       "      <td>456.0</td>\n",
       "      <td>2005</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>Tomb</td>\n",
       "      <td>Great Pyramid of Giza</td>\n",
       "      <td>Egypt</td>\n",
       "      <td>Giza</td>\n",
       "      <td>138.80</td>\n",
       "      <td>455.2</td>\n",
       "      <td>2560 BCE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>Drop tower</td>\n",
       "      <td>Zumanjaro: Drop of Doom</td>\n",
       "      <td>United States</td>\n",
       "      <td>Jackson Township, NJ</td>\n",
       "      <td>139.00</td>\n",
       "      <td>456.0</td>\n",
       "      <td>2014</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>Gantry crane</td>\n",
       "      <td>Kockums Crane</td>\n",
       "      <td>South Korea</td>\n",
       "      <td>Ulsan</td>\n",
       "      <td>135.90</td>\n",
       "      <td>453.0</td>\n",
       "      <td>1974</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>Stupa</td>\n",
       "      <td>Jetavanaramaya</td>\n",
       "      <td>Sri Lanka</td>\n",
       "      <td>Anuradhapura</td>\n",
       "      <td>122.00</td>\n",
       "      <td>400.0</td>\n",
       "      <td>273–301 CE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>Wooden structure</td>\n",
       "      <td>Gliwice Radio Tower</td>\n",
       "      <td>Poland</td>\n",
       "      <td>Gliwice</td>\n",
       "      <td>118.00</td>\n",
       "      <td>387.0</td>\n",
       "      <td>1935</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>Storage silo</td>\n",
       "      <td>Swissmill Tower</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Zurich</td>\n",
       "      <td>118.00</td>\n",
       "      <td>387.0</td>\n",
       "      <td>2016</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>Gasometer</td>\n",
       "      <td>Gasometer Oberhausen</td>\n",
       "      <td>Germany</td>\n",
       "      <td>Oberhausen</td>\n",
       "      <td>117.50</td>\n",
       "      <td>386.0</td>\n",
       "      <td>1929</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>Clock tower</td>\n",
       "      <td>Joseph Chamberlain Memorial Clock Tower</td>\n",
       "      <td>United Kingdom</td>\n",
       "      <td>Birmingham</td>\n",
       "      <td>98.40</td>\n",
       "      <td>328.0</td>\n",
       "      <td>1908</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>Sphere</td>\n",
       "      <td>Avicii Arena</td>\n",
       "      <td>Sweden</td>\n",
       "      <td>Stockholm</td>\n",
       "      <td>85.00</td>\n",
       "      <td>279.0</td>\n",
       "      <td>1989</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>Gopuram</td>\n",
       "      <td>Murudeshwara Temple</td>\n",
       "      <td>India</td>\n",
       "      <td>Murudeshwara</td>\n",
       "      <td>76.00</td>\n",
       "      <td>249.0</td>\n",
       "      <td>2008</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                        Category  \\\n",
       "0                    Building[5]   \n",
       "1                Compliant tower   \n",
       "2       Self-supporting tower[6]   \n",
       "3       Guyed steel lattice mast   \n",
       "4          Hyperboloid structure   \n",
       "5                    Clock tower   \n",
       "7                Moveable object   \n",
       "8                  Mast radiator   \n",
       "9                  Twin building   \n",
       "10             Steel building[7]   \n",
       "11                       Chimney   \n",
       "13                 Lattice tower   \n",
       "14             Electricity pylon   \n",
       "15         Fixed steel structure   \n",
       "16         Partially guyed tower   \n",
       "17      Guyed tubular steel mast   \n",
       "18                        Bridge   \n",
       "20                           Dam   \n",
       "21         Landmark Tower design   \n",
       "22           Elevator test tower   \n",
       "23                  Wind turbine   \n",
       "24             Solar power tower   \n",
       "25                         Crane   \n",
       "26                    Jackup rig   \n",
       "27                 Cooling tower   \n",
       "28                      Monument   \n",
       "29  Aerial tramway support tower   \n",
       "30                   Water tower   \n",
       "31                        Statue   \n",
       "32                 Masonry tower   \n",
       "33            Inclined structure   \n",
       "35                       Obelisk   \n",
       "36        Power station building   \n",
       "37                      Flagpole   \n",
       "38                  Ferris wheel   \n",
       "39              Masonry building   \n",
       "40               Industrial hall   \n",
       "41     Air traffic control tower   \n",
       "42                Roller coaster   \n",
       "43                          Tomb   \n",
       "44                    Drop tower   \n",
       "45                  Gantry crane   \n",
       "46                         Stupa   \n",
       "47              Wooden structure   \n",
       "48                  Storage silo   \n",
       "50                     Gasometer   \n",
       "51                   Clock tower   \n",
       "52                        Sphere   \n",
       "53                       Gopuram   \n",
       "\n",
       "                                            Structure               Country  \\\n",
       "0                                        Burj Khalifa  United Arab Emirates   \n",
       "1                                           Petronius         United States   \n",
       "2                                       Tokyo Skytree                 Japan   \n",
       "3                                        KVLY-TV mast         United States   \n",
       "4                                        Canton Tower                 China   \n",
       "5                                       Abraj Al Bait          Saudi Arabia   \n",
       "7                                    Troll A platform                Norway   \n",
       "8                           Lualualei VLF transmitter         United States   \n",
       "9                                Petronas Twin Towers              Malaysia   \n",
       "10                                       Willis Tower         United States   \n",
       "11                     Ekibastuz GRES-2 Power Station            Kazakhstan   \n",
       "13                                      Kyiv TV Tower               Ukraine   \n",
       "14               Jintang-Cezi Overhead Powerline Link                 China   \n",
       "15                                         Bullwinkle         United States   \n",
       "16                                    Gerbrandy Tower           Netherlands   \n",
       "17                                 TV Tower Vinnytsia               Ukraine   \n",
       "18                                     Millau Viaduct                France   \n",
       "20                                      Jinping-I Dam                 China   \n",
       "21                                         Star Tower         United States   \n",
       "22                                           H1 Tower                 China   \n",
       "23                                Haliade-X Prototype           Netherlands   \n",
       "24          Mohammed bin Rashid Al Maktoum Solar Park  United Arab Emirates   \n",
       "25                                        LR 13000[8]               Germany   \n",
       "26                               Noble Lloyd Noble[9]               Liberia   \n",
       "27                    Kalisindh Thermal Power Station                 India   \n",
       "28                                       Gateway Arch         United States   \n",
       "29             Tower 2 of Ha Long Queen Cable Car[11]               Vietnam   \n",
       "30                        Main tower of Kuwait Towers                Kuwait   \n",
       "31                                    Statue of Unity                 India   \n",
       "32                             Anaconda Smelter Stack         United States   \n",
       "33                                    Olympic Stadium                Canada   \n",
       "35                               San Jacinto Monument         United States   \n",
       "36                         Niederaussem Power Station               Germany   \n",
       "37                                    Jeddah Flagpole          Saudi Arabia   \n",
       "38                                        High Roller         United States   \n",
       "39                                  Mole Antonelliana                 Italy   \n",
       "40                          Vehicle Assembly Building         United States   \n",
       "41  Kuala Lumpur International Airport 2 Control T...              Malaysia   \n",
       "42                                          Kingda Ka         United States   \n",
       "43                              Great Pyramid of Giza                 Egypt   \n",
       "44                            Zumanjaro: Drop of Doom         United States   \n",
       "45                                      Kockums Crane           South Korea   \n",
       "46                                     Jetavanaramaya             Sri Lanka   \n",
       "47                                Gliwice Radio Tower                Poland   \n",
       "48                                    Swissmill Tower           Switzerland   \n",
       "50                               Gasometer Oberhausen               Germany   \n",
       "51            Joseph Chamberlain Memorial Clock Tower        United Kingdom   \n",
       "52                                       Avicii Arena                Sweden   \n",
       "53                                Murudeshwara Temple                 India   \n",
       "\n",
       "                             City  Height (meters)  Height (feet)  Year built  \n",
       "0                           Dubai           816.60         2722.0        2010  \n",
       "1                  Gulf of Mexico           640.00         2100.0        2000  \n",
       "2                           Tokyo           634.00         2080.0        2011  \n",
       "3         Blanchard, North Dakota           629.00         2063.0        1963  \n",
       "4                       Guangzhou           604.00         1982.0        2010  \n",
       "5                           Mecca           601.00         1972.0        2012  \n",
       "7                       North Sea           472.00         1549.0        1996  \n",
       "8               Lualualei, Hawaii           458.00         1503.0        1972  \n",
       "9                    Kuala Lumpur           452.00         1482.0        1998  \n",
       "10              Chicago, Illinois           442.00         1450.0        1974  \n",
       "11                      Ekibastuz           419.70         1377.0        1987  \n",
       "13                           Kyiv           385.00         1263.0        1973  \n",
       "14                 Jintang Island           380.00         1247.0        2019  \n",
       "15                 Gulf of Mexico           529.00         1736.0        1988  \n",
       "16                    IJsselstein           366.80         1203.0        1961  \n",
       "17                      Vinnytsia           354.00         1161.0        1961  \n",
       "18                         Millau           342.00         1122.0        2004  \n",
       "20                      Liangshan           305.00         1001.0        2013  \n",
       "21                     Cincinnati           291.00          954.0        1991  \n",
       "22                      Guangzhou           273.80          898.0        2020  \n",
       "23                      Rotterdam           270.00          886.0        2019  \n",
       "24                  Saih Al-Dahal           262.00          860.0        2020  \n",
       "25                        Germany           248.00          814.0        2013  \n",
       "26                        Liberia           214.00          702.0        2016  \n",
       "27                       Jhalawar           198.90          663.0        2012  \n",
       "28            St. Louis, Missouri           192.00          630.0        1965  \n",
       "29                        Vietnam           189.00          620.0        2016  \n",
       "30                    Kuwait City           187.00          614.0        1979  \n",
       "31      Narmada district, Gujarat           179.10          597.0        2018  \n",
       "32              Anaconda, Montana           178.30          585.0        1919  \n",
       "33                       Montreal           175.00          574.0        1976  \n",
       "35                La Porte, Texas           173.70          570.0        1939  \n",
       "36                       Bergheim           172.00          564.0        2002  \n",
       "37                         Jeddah           168.30          561.0        2014  \n",
       "38                      Las Vegas           167.60          550.0        2014  \n",
       "39                         Torino           167.50          550.0        1889  \n",
       "40  Kennedy Space Center, Florida           160.00          525.0        1966  \n",
       "41                         Sepang           141.30          463.6    2013[13]  \n",
       "42            Jackson, New Jersey           138.98          456.0        2005  \n",
       "43                           Giza           138.80          455.2    2560 BCE  \n",
       "44           Jackson Township, NJ           139.00          456.0        2014  \n",
       "45                          Ulsan           135.90          453.0        1974  \n",
       "46                   Anuradhapura           122.00          400.0  273–301 CE  \n",
       "47                        Gliwice           118.00          387.0        1935  \n",
       "48                         Zurich           118.00          387.0        2016  \n",
       "50                     Oberhausen           117.50          386.0        1929  \n",
       "51                     Birmingham            98.40          328.0        1908  \n",
       "52                      Stockholm            85.00          279.0        1989  \n",
       "53                   Murudeshwara            76.00          249.0        2008  "
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#replacing missing values in City with its respective Country\n",
    "tallest.City = np.where(tallest.City.isnull(), tallest.Country, tallest.City)\n",
    "tallest"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a5942d45",
   "metadata": {},
   "source": [
    "(h) Show that there are no missing values in tallest."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "df6aec58",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of missing values in each column\n",
      "Category           0\n",
      "Structure          0\n",
      "Country            0\n",
      "City               0\n",
      "Height (meters)    0\n",
      "Height (feet)      0\n",
      "Year built         0\n",
      "dtype: int64\n"
     ]
    }
   ],
   "source": [
    "print('Number of missing values in each column')\n",
    "print(tallest.isna().sum())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "727136fa",
   "metadata": {},
   "source": [
    "(i) Create a function named eliminate_ref. This function will receive an array and perform these \n",
    "tasks:\n",
    "    \n",
    "    (i) find whether there is any reference attached to any string in the array given. Commonly, any \n",
    "    references can be detected by a square bracket containing a number like [5] \n",
    "    (ii) If there is any reference attached, replace the word with the original word but without \n",
    "    the reference. Set inplace=True when performing the replace method.\n",
    "    Test your function using these codes\n",
    "    eliminate_ref(tallest['Category']) \n",
    "    eliminate_ref(tallest['Structure'])\n",
    "    tallest"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "960ecbef",
   "metadata": {},
   "source": [
    "import re\n",
    "def eliminate_ref(column):\n",
    "    column = re.sub(\"\\(.*?\\)|\\[.*?\\]\",\"\",column)\n",
    "    return column \n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "d4b968b4",
   "metadata": {},
   "outputs": [
    {
     "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>Category</th>\n",
       "      <th>Structure</th>\n",
       "      <th>Country</th>\n",
       "      <th>City</th>\n",
       "      <th>Height (meters)</th>\n",
       "      <th>Height (feet)</th>\n",
       "      <th>Year built</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Building</td>\n",
       "      <td>Burj Khalifa</td>\n",
       "      <td>United Arab Emirates</td>\n",
       "      <td>Dubai</td>\n",
       "      <td>816.60</td>\n",
       "      <td>2722.0</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Compliant tower</td>\n",
       "      <td>Petronius</td>\n",
       "      <td>United States</td>\n",
       "      <td>Gulf of Mexico</td>\n",
       "      <td>640.00</td>\n",
       "      <td>2100.0</td>\n",
       "      <td>2000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Self-supporting tower</td>\n",
       "      <td>Tokyo Skytree</td>\n",
       "      <td>Japan</td>\n",
       "      <td>Tokyo</td>\n",
       "      <td>634.00</td>\n",
       "      <td>2080.0</td>\n",
       "      <td>2011</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Guyed steel lattice mast</td>\n",
       "      <td>KVLY-TV mast</td>\n",
       "      <td>United States</td>\n",
       "      <td>Blanchard, North Dakota</td>\n",
       "      <td>629.00</td>\n",
       "      <td>2063.0</td>\n",
       "      <td>1963</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Hyperboloid structure</td>\n",
       "      <td>Canton Tower</td>\n",
       "      <td>China</td>\n",
       "      <td>Guangzhou</td>\n",
       "      <td>604.00</td>\n",
       "      <td>1982.0</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Clock tower</td>\n",
       "      <td>Abraj Al Bait</td>\n",
       "      <td>Saudi Arabia</td>\n",
       "      <td>Mecca</td>\n",
       "      <td>601.00</td>\n",
       "      <td>1972.0</td>\n",
       "      <td>2012</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Moveable object</td>\n",
       "      <td>Troll A platform</td>\n",
       "      <td>Norway</td>\n",
       "      <td>North Sea</td>\n",
       "      <td>472.00</td>\n",
       "      <td>1549.0</td>\n",
       "      <td>1996</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Mast radiator</td>\n",
       "      <td>Lualualei VLF transmitter</td>\n",
       "      <td>United States</td>\n",
       "      <td>Lualualei, Hawaii</td>\n",
       "      <td>458.00</td>\n",
       "      <td>1503.0</td>\n",
       "      <td>1972</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Twin building</td>\n",
       "      <td>Petronas Twin Towers</td>\n",
       "      <td>Malaysia</td>\n",
       "      <td>Kuala Lumpur</td>\n",
       "      <td>452.00</td>\n",
       "      <td>1482.0</td>\n",
       "      <td>1998</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>Steel building</td>\n",
       "      <td>Willis Tower</td>\n",
       "      <td>United States</td>\n",
       "      <td>Chicago, Illinois</td>\n",
       "      <td>442.00</td>\n",
       "      <td>1450.0</td>\n",
       "      <td>1974</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>Chimney</td>\n",
       "      <td>Ekibastuz GRES-2 Power Station</td>\n",
       "      <td>Kazakhstan</td>\n",
       "      <td>Ekibastuz</td>\n",
       "      <td>419.70</td>\n",
       "      <td>1377.0</td>\n",
       "      <td>1987</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>Lattice tower</td>\n",
       "      <td>Kyiv TV Tower</td>\n",
       "      <td>Ukraine</td>\n",
       "      <td>Kyiv</td>\n",
       "      <td>385.00</td>\n",
       "      <td>1263.0</td>\n",
       "      <td>1973</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>Electricity pylon</td>\n",
       "      <td>Jintang-Cezi Overhead Powerline Link</td>\n",
       "      <td>China</td>\n",
       "      <td>Jintang Island</td>\n",
       "      <td>380.00</td>\n",
       "      <td>1247.0</td>\n",
       "      <td>2019</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>Fixed steel structure</td>\n",
       "      <td>Bullwinkle</td>\n",
       "      <td>United States</td>\n",
       "      <td>Gulf of Mexico</td>\n",
       "      <td>529.00</td>\n",
       "      <td>1736.0</td>\n",
       "      <td>1988</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>Partially guyed tower</td>\n",
       "      <td>Gerbrandy Tower</td>\n",
       "      <td>Netherlands</td>\n",
       "      <td>IJsselstein</td>\n",
       "      <td>366.80</td>\n",
       "      <td>1203.0</td>\n",
       "      <td>1961</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>Guyed tubular steel mast</td>\n",
       "      <td>TV Tower Vinnytsia</td>\n",
       "      <td>Ukraine</td>\n",
       "      <td>Vinnytsia</td>\n",
       "      <td>354.00</td>\n",
       "      <td>1161.0</td>\n",
       "      <td>1961</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>Bridge</td>\n",
       "      <td>Millau Viaduct</td>\n",
       "      <td>France</td>\n",
       "      <td>Millau</td>\n",
       "      <td>342.00</td>\n",
       "      <td>1122.0</td>\n",
       "      <td>2004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>Dam</td>\n",
       "      <td>Jinping-I Dam</td>\n",
       "      <td>China</td>\n",
       "      <td>Liangshan</td>\n",
       "      <td>305.00</td>\n",
       "      <td>1001.0</td>\n",
       "      <td>2013</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>Landmark Tower design</td>\n",
       "      <td>Star Tower</td>\n",
       "      <td>United States</td>\n",
       "      <td>Cincinnati</td>\n",
       "      <td>291.00</td>\n",
       "      <td>954.0</td>\n",
       "      <td>1991</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>Elevator test tower</td>\n",
       "      <td>H1 Tower</td>\n",
       "      <td>China</td>\n",
       "      <td>Guangzhou</td>\n",
       "      <td>273.80</td>\n",
       "      <td>898.0</td>\n",
       "      <td>2020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>Wind turbine</td>\n",
       "      <td>Haliade-X Prototype</td>\n",
       "      <td>Netherlands</td>\n",
       "      <td>Rotterdam</td>\n",
       "      <td>270.00</td>\n",
       "      <td>886.0</td>\n",
       "      <td>2019</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>Solar power tower</td>\n",
       "      <td>Mohammed bin Rashid Al Maktoum Solar Park</td>\n",
       "      <td>United Arab Emirates</td>\n",
       "      <td>Saih Al-Dahal</td>\n",
       "      <td>262.00</td>\n",
       "      <td>860.0</td>\n",
       "      <td>2020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>Crane</td>\n",
       "      <td>LR 13000</td>\n",
       "      <td>Germany</td>\n",
       "      <td>Germany</td>\n",
       "      <td>248.00</td>\n",
       "      <td>814.0</td>\n",
       "      <td>2013</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>Jackup rig</td>\n",
       "      <td>Noble Lloyd Noble</td>\n",
       "      <td>Liberia</td>\n",
       "      <td>Liberia</td>\n",
       "      <td>214.00</td>\n",
       "      <td>702.0</td>\n",
       "      <td>2016</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>Cooling tower</td>\n",
       "      <td>Kalisindh Thermal Power Station</td>\n",
       "      <td>India</td>\n",
       "      <td>Jhalawar</td>\n",
       "      <td>198.90</td>\n",
       "      <td>663.0</td>\n",
       "      <td>2012</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>Monument</td>\n",
       "      <td>Gateway Arch</td>\n",
       "      <td>United States</td>\n",
       "      <td>St. Louis, Missouri</td>\n",
       "      <td>192.00</td>\n",
       "      <td>630.0</td>\n",
       "      <td>1965</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>Aerial tramway support tower</td>\n",
       "      <td>Tower 2 of Ha Long Queen Cable Car</td>\n",
       "      <td>Vietnam</td>\n",
       "      <td>Vietnam</td>\n",
       "      <td>189.00</td>\n",
       "      <td>620.0</td>\n",
       "      <td>2016</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>Water tower</td>\n",
       "      <td>Main tower of Kuwait Towers</td>\n",
       "      <td>Kuwait</td>\n",
       "      <td>Kuwait City</td>\n",
       "      <td>187.00</td>\n",
       "      <td>614.0</td>\n",
       "      <td>1979</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>Statue</td>\n",
       "      <td>Statue of Unity</td>\n",
       "      <td>India</td>\n",
       "      <td>Narmada district, Gujarat</td>\n",
       "      <td>179.10</td>\n",
       "      <td>597.0</td>\n",
       "      <td>2018</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>Masonry tower</td>\n",
       "      <td>Anaconda Smelter Stack</td>\n",
       "      <td>United States</td>\n",
       "      <td>Anaconda, Montana</td>\n",
       "      <td>178.30</td>\n",
       "      <td>585.0</td>\n",
       "      <td>1919</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>Inclined structure</td>\n",
       "      <td>Olympic Stadium</td>\n",
       "      <td>Canada</td>\n",
       "      <td>Montreal</td>\n",
       "      <td>175.00</td>\n",
       "      <td>574.0</td>\n",
       "      <td>1976</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>Obelisk</td>\n",
       "      <td>San Jacinto Monument</td>\n",
       "      <td>United States</td>\n",
       "      <td>La Porte, Texas</td>\n",
       "      <td>173.70</td>\n",
       "      <td>570.0</td>\n",
       "      <td>1939</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>Power station building</td>\n",
       "      <td>Niederaussem Power Station</td>\n",
       "      <td>Germany</td>\n",
       "      <td>Bergheim</td>\n",
       "      <td>172.00</td>\n",
       "      <td>564.0</td>\n",
       "      <td>2002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>Flagpole</td>\n",
       "      <td>Jeddah Flagpole</td>\n",
       "      <td>Saudi Arabia</td>\n",
       "      <td>Jeddah</td>\n",
       "      <td>168.30</td>\n",
       "      <td>561.0</td>\n",
       "      <td>2014</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>Ferris wheel</td>\n",
       "      <td>High Roller</td>\n",
       "      <td>United States</td>\n",
       "      <td>Las Vegas</td>\n",
       "      <td>167.60</td>\n",
       "      <td>550.0</td>\n",
       "      <td>2014</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>Masonry building</td>\n",
       "      <td>Mole Antonelliana</td>\n",
       "      <td>Italy</td>\n",
       "      <td>Torino</td>\n",
       "      <td>167.50</td>\n",
       "      <td>550.0</td>\n",
       "      <td>1889</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>Industrial hall</td>\n",
       "      <td>Vehicle Assembly Building</td>\n",
       "      <td>United States</td>\n",
       "      <td>Kennedy Space Center, Florida</td>\n",
       "      <td>160.00</td>\n",
       "      <td>525.0</td>\n",
       "      <td>1966</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>Air traffic control tower</td>\n",
       "      <td>Kuala Lumpur International Airport 2 Control T...</td>\n",
       "      <td>Malaysia</td>\n",
       "      <td>Sepang</td>\n",
       "      <td>141.30</td>\n",
       "      <td>463.6</td>\n",
       "      <td>2013[13]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>Roller coaster</td>\n",
       "      <td>Kingda Ka</td>\n",
       "      <td>United States</td>\n",
       "      <td>Jackson, New Jersey</td>\n",
       "      <td>138.98</td>\n",
       "      <td>456.0</td>\n",
       "      <td>2005</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>Tomb</td>\n",
       "      <td>Great Pyramid of Giza</td>\n",
       "      <td>Egypt</td>\n",
       "      <td>Giza</td>\n",
       "      <td>138.80</td>\n",
       "      <td>455.2</td>\n",
       "      <td>2560 BCE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>Drop tower</td>\n",
       "      <td>Zumanjaro: Drop of Doom</td>\n",
       "      <td>United States</td>\n",
       "      <td>Jackson Township, NJ</td>\n",
       "      <td>139.00</td>\n",
       "      <td>456.0</td>\n",
       "      <td>2014</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>Gantry crane</td>\n",
       "      <td>Kockums Crane</td>\n",
       "      <td>South Korea</td>\n",
       "      <td>Ulsan</td>\n",
       "      <td>135.90</td>\n",
       "      <td>453.0</td>\n",
       "      <td>1974</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>Stupa</td>\n",
       "      <td>Jetavanaramaya</td>\n",
       "      <td>Sri Lanka</td>\n",
       "      <td>Anuradhapura</td>\n",
       "      <td>122.00</td>\n",
       "      <td>400.0</td>\n",
       "      <td>273–301 CE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>Wooden structure</td>\n",
       "      <td>Gliwice Radio Tower</td>\n",
       "      <td>Poland</td>\n",
       "      <td>Gliwice</td>\n",
       "      <td>118.00</td>\n",
       "      <td>387.0</td>\n",
       "      <td>1935</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>Storage silo</td>\n",
       "      <td>Swissmill Tower</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Zurich</td>\n",
       "      <td>118.00</td>\n",
       "      <td>387.0</td>\n",
       "      <td>2016</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>Gasometer</td>\n",
       "      <td>Gasometer Oberhausen</td>\n",
       "      <td>Germany</td>\n",
       "      <td>Oberhausen</td>\n",
       "      <td>117.50</td>\n",
       "      <td>386.0</td>\n",
       "      <td>1929</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>Clock tower</td>\n",
       "      <td>Joseph Chamberlain Memorial Clock Tower</td>\n",
       "      <td>United Kingdom</td>\n",
       "      <td>Birmingham</td>\n",
       "      <td>98.40</td>\n",
       "      <td>328.0</td>\n",
       "      <td>1908</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>Sphere</td>\n",
       "      <td>Avicii Arena</td>\n",
       "      <td>Sweden</td>\n",
       "      <td>Stockholm</td>\n",
       "      <td>85.00</td>\n",
       "      <td>279.0</td>\n",
       "      <td>1989</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>Gopuram</td>\n",
       "      <td>Murudeshwara Temple</td>\n",
       "      <td>India</td>\n",
       "      <td>Murudeshwara</td>\n",
       "      <td>76.00</td>\n",
       "      <td>249.0</td>\n",
       "      <td>2008</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                        Category  \\\n",
       "0                       Building   \n",
       "1                Compliant tower   \n",
       "2          Self-supporting tower   \n",
       "3       Guyed steel lattice mast   \n",
       "4          Hyperboloid structure   \n",
       "5                    Clock tower   \n",
       "7                Moveable object   \n",
       "8                  Mast radiator   \n",
       "9                  Twin building   \n",
       "10                Steel building   \n",
       "11                       Chimney   \n",
       "13                 Lattice tower   \n",
       "14             Electricity pylon   \n",
       "15         Fixed steel structure   \n",
       "16         Partially guyed tower   \n",
       "17      Guyed tubular steel mast   \n",
       "18                        Bridge   \n",
       "20                           Dam   \n",
       "21         Landmark Tower design   \n",
       "22           Elevator test tower   \n",
       "23                  Wind turbine   \n",
       "24             Solar power tower   \n",
       "25                         Crane   \n",
       "26                    Jackup rig   \n",
       "27                 Cooling tower   \n",
       "28                      Monument   \n",
       "29  Aerial tramway support tower   \n",
       "30                   Water tower   \n",
       "31                        Statue   \n",
       "32                 Masonry tower   \n",
       "33            Inclined structure   \n",
       "35                       Obelisk   \n",
       "36        Power station building   \n",
       "37                      Flagpole   \n",
       "38                  Ferris wheel   \n",
       "39              Masonry building   \n",
       "40               Industrial hall   \n",
       "41     Air traffic control tower   \n",
       "42                Roller coaster   \n",
       "43                          Tomb   \n",
       "44                    Drop tower   \n",
       "45                  Gantry crane   \n",
       "46                         Stupa   \n",
       "47              Wooden structure   \n",
       "48                  Storage silo   \n",
       "50                     Gasometer   \n",
       "51                   Clock tower   \n",
       "52                        Sphere   \n",
       "53                       Gopuram   \n",
       "\n",
       "                                            Structure               Country  \\\n",
       "0                                        Burj Khalifa  United Arab Emirates   \n",
       "1                                           Petronius         United States   \n",
       "2                                       Tokyo Skytree                 Japan   \n",
       "3                                        KVLY-TV mast         United States   \n",
       "4                                        Canton Tower                 China   \n",
       "5                                       Abraj Al Bait          Saudi Arabia   \n",
       "7                                    Troll A platform                Norway   \n",
       "8                           Lualualei VLF transmitter         United States   \n",
       "9                                Petronas Twin Towers              Malaysia   \n",
       "10                                       Willis Tower         United States   \n",
       "11                     Ekibastuz GRES-2 Power Station            Kazakhstan   \n",
       "13                                      Kyiv TV Tower               Ukraine   \n",
       "14               Jintang-Cezi Overhead Powerline Link                 China   \n",
       "15                                         Bullwinkle         United States   \n",
       "16                                    Gerbrandy Tower           Netherlands   \n",
       "17                                 TV Tower Vinnytsia               Ukraine   \n",
       "18                                     Millau Viaduct                France   \n",
       "20                                      Jinping-I Dam                 China   \n",
       "21                                         Star Tower         United States   \n",
       "22                                           H1 Tower                 China   \n",
       "23                                Haliade-X Prototype           Netherlands   \n",
       "24          Mohammed bin Rashid Al Maktoum Solar Park  United Arab Emirates   \n",
       "25                                           LR 13000               Germany   \n",
       "26                                  Noble Lloyd Noble               Liberia   \n",
       "27                    Kalisindh Thermal Power Station                 India   \n",
       "28                                       Gateway Arch         United States   \n",
       "29                 Tower 2 of Ha Long Queen Cable Car               Vietnam   \n",
       "30                        Main tower of Kuwait Towers                Kuwait   \n",
       "31                                    Statue of Unity                 India   \n",
       "32                             Anaconda Smelter Stack         United States   \n",
       "33                                    Olympic Stadium                Canada   \n",
       "35                               San Jacinto Monument         United States   \n",
       "36                         Niederaussem Power Station               Germany   \n",
       "37                                    Jeddah Flagpole          Saudi Arabia   \n",
       "38                                        High Roller         United States   \n",
       "39                                  Mole Antonelliana                 Italy   \n",
       "40                          Vehicle Assembly Building         United States   \n",
       "41  Kuala Lumpur International Airport 2 Control T...              Malaysia   \n",
       "42                                          Kingda Ka         United States   \n",
       "43                              Great Pyramid of Giza                 Egypt   \n",
       "44                            Zumanjaro: Drop of Doom         United States   \n",
       "45                                      Kockums Crane           South Korea   \n",
       "46                                     Jetavanaramaya             Sri Lanka   \n",
       "47                                Gliwice Radio Tower                Poland   \n",
       "48                                    Swissmill Tower           Switzerland   \n",
       "50                               Gasometer Oberhausen               Germany   \n",
       "51            Joseph Chamberlain Memorial Clock Tower        United Kingdom   \n",
       "52                                       Avicii Arena                Sweden   \n",
       "53                                Murudeshwara Temple                 India   \n",
       "\n",
       "                             City  Height (meters)  Height (feet)  Year built  \n",
       "0                           Dubai           816.60         2722.0        2010  \n",
       "1                  Gulf of Mexico           640.00         2100.0        2000  \n",
       "2                           Tokyo           634.00         2080.0        2011  \n",
       "3         Blanchard, North Dakota           629.00         2063.0        1963  \n",
       "4                       Guangzhou           604.00         1982.0        2010  \n",
       "5                           Mecca           601.00         1972.0        2012  \n",
       "7                       North Sea           472.00         1549.0        1996  \n",
       "8               Lualualei, Hawaii           458.00         1503.0        1972  \n",
       "9                    Kuala Lumpur           452.00         1482.0        1998  \n",
       "10              Chicago, Illinois           442.00         1450.0        1974  \n",
       "11                      Ekibastuz           419.70         1377.0        1987  \n",
       "13                           Kyiv           385.00         1263.0        1973  \n",
       "14                 Jintang Island           380.00         1247.0        2019  \n",
       "15                 Gulf of Mexico           529.00         1736.0        1988  \n",
       "16                    IJsselstein           366.80         1203.0        1961  \n",
       "17                      Vinnytsia           354.00         1161.0        1961  \n",
       "18                         Millau           342.00         1122.0        2004  \n",
       "20                      Liangshan           305.00         1001.0        2013  \n",
       "21                     Cincinnati           291.00          954.0        1991  \n",
       "22                      Guangzhou           273.80          898.0        2020  \n",
       "23                      Rotterdam           270.00          886.0        2019  \n",
       "24                  Saih Al-Dahal           262.00          860.0        2020  \n",
       "25                        Germany           248.00          814.0        2013  \n",
       "26                        Liberia           214.00          702.0        2016  \n",
       "27                       Jhalawar           198.90          663.0        2012  \n",
       "28            St. Louis, Missouri           192.00          630.0        1965  \n",
       "29                        Vietnam           189.00          620.0        2016  \n",
       "30                    Kuwait City           187.00          614.0        1979  \n",
       "31      Narmada district, Gujarat           179.10          597.0        2018  \n",
       "32              Anaconda, Montana           178.30          585.0        1919  \n",
       "33                       Montreal           175.00          574.0        1976  \n",
       "35                La Porte, Texas           173.70          570.0        1939  \n",
       "36                       Bergheim           172.00          564.0        2002  \n",
       "37                         Jeddah           168.30          561.0        2014  \n",
       "38                      Las Vegas           167.60          550.0        2014  \n",
       "39                         Torino           167.50          550.0        1889  \n",
       "40  Kennedy Space Center, Florida           160.00          525.0        1966  \n",
       "41                         Sepang           141.30          463.6    2013[13]  \n",
       "42            Jackson, New Jersey           138.98          456.0        2005  \n",
       "43                           Giza           138.80          455.2    2560 BCE  \n",
       "44           Jackson Township, NJ           139.00          456.0        2014  \n",
       "45                          Ulsan           135.90          453.0        1974  \n",
       "46                   Anuradhapura           122.00          400.0  273–301 CE  \n",
       "47                        Gliwice           118.00          387.0        1935  \n",
       "48                         Zurich           118.00          387.0        2016  \n",
       "50                     Oberhausen           117.50          386.0        1929  \n",
       "51                     Birmingham            98.40          328.0        1908  \n",
       "52                      Stockholm            85.00          279.0        1989  \n",
       "53                   Murudeshwara            76.00          249.0        2008  "
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def eliminate_ref(arr):\n",
    "    result = [x.split('[')[0] for x in arr]\n",
    "    \n",
    "    return result\n",
    "\n",
    "\n",
    "\n",
    "tallest['Category'] = eliminate_ref(tallest['Category']) \n",
    "tallest['Structure'] = eliminate_ref(tallest['Structure'])\n",
    "tallest"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
