Great Deal! Get Instant \$10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

# Already give to the agent

Answered Same Day Jun 02, 2020

## Solution

Abr Writing answered on Jun 03 2020
{
"cells": [
{
"cell_type": "markdown",
"source": [
"## Importing necessary dependencies"
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
]
},
{
"cell_type": "markdown",
"source": [
"## Defining Constants"
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"HOME_PAGE = 'index.html'\n",
"PAGE_1 = 'total-passengers-per-year.html'\n",
"PAGE_2 = 'total-passengers-per-year-per-airport.html'\n",
"PAGE_3 = 'total-passengers-per-year-per-state.html'\n",
"PAGE_4 = 'seasonal-passengers-per-year-per-airport.html'\n",
"PAGE_5 ='seasonal-passengers-per-year-per-state.html'\n",
"PAGE_6 = 'tourists-vs-residents-page.html'"
]
},
{
"cell_type": "markdown",
"source": [
"## Defining Servers"
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
]
},
{
"cell_type": "markdown",
"source": [
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"df1 = pd.read_csv('./1.csv', encoding = 'utf8')\n",
"\n",
"df2 = pd.read_csv('./2.csv', encoding = 'utf8')\n",
"df2 = df2.drop(df2.index[[0,1,2,3,4,5,6,7,8]])\n",
"df2 = df2.iloc[[0,1,2,3,4,5,6,7,8,9,10,11]].reset_index().drop('index',axis=1)\n",
"df2 = df2[['Number of movements ; Total (Country of stay
esidence) ; Short-term Visitors a
iving ;']]\n",
"df2.columns = ['Tourists']\n",
"df2 = df2.apply(pd.to_numeric)\n",
"\n",
"\n",
"dfg_airport = df1.groupby(['AIRPORT','Year'])\n",
"df_airports = dfg_airport.aggregate(np.sum).reset_index()\n",
"df_airports = df_airports.drop('Month',axis=1)\n",
"\n",
"airports = df1['AIRPORT'].unique()\n",
"\n",
"states_dict = {\n",
" \"New South Wales\": [\"BALLINA\",\"SYDNEY\",\"CANBERRA\",\"NEWCASTLE\"],\n",
" \"Northern Te
itory\": [\"ALICE SPRINGS\",\"DARWIN\"],\n",
" \"Queensland\":[\"BRISBANE\",\"CAIRNS\",\"GOLD COAST\",\"HAMILTON ISLAND\",\"MACKAY\",\"ROCKHAMPTON\",\"SUNSHINE COAST\",\"TOWNSVILLE\"],\n",
" \"Tasmania\":[\"HOBART\",\"LAUNCESTON\"],\n",
" \"Vicoria\":[\"MELBOURNE\"],\n",
" \"Western Australia\":[\"KARRATHA\",\"PERTH\"],\n",
"}\n",
"\n",
"df_states_dict = {}\n",
"for state in states_dict:\n",
" df_states_dict[state] = df_airports[df_airports['AIRPORT'].isin(states_dict[state])].drop('AIRPORT',axis=1)\n",
" df_states_dict[state] = df_states_dict[state].groupby(['Year']).aggregate(np.sum).reset_index()\n",
" \n",
"df_summer = df1[df1['Month'].isin([12,1,2])].drop('Month',axis=1).groupby(['AIRPORT','Year']).aggregate(np.sum).reset_index()\n",
"df_winter = df1[df1['Month'].isin([6,7,8])].drop('Month',axis=1).groupby(['AIRPORT','Year']).aggregate(np.sum).reset_index()\n",
"\n",
"df_states_summer_dict = {}\n",
"for state in states_dict:\n",
" df_states_summer_dict[state] = df_summer[df_summer['AIRPORT'].isin(states_dict[state])].drop('AIRPORT',axis=1)\n",
" df_states_summer_dict[state] = df_states_summer_dict[state].groupby(['Year']).aggregate(np.sum).reset_index() \n",
...
SOLUTION.PDF