description in attached files. this project had 2 parts before that are attached, part of the work is already done, found in the assignment word doc. probably need the panda database done as well...

1 answer below »
description in attached files. this project had 2 parts before that are attached, part of the work is already done, found in the assignment word doc. probably need the panda database done as well (although not sure) or at least screenshots. message me if any confusions or questions.ps i had a quote for an older assignment but ended up not using your services, it says project is pending so idk if it charged me for it or not, if so please just cancel the last project and only look at this one
Answered Same DayNov 13, 2021

Answer To: description in attached files. this project had 2 parts before that are attached, part of the work...

Ximi answered on Nov 18 2021
139 Votes
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import sqlite3"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"connection = sqlite3.connect('Proj2earfquak/index.sqlite')\n",
"cursor = connection.cursor()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
""
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cursor.execute(\"SELECT * FROM Earthquakes;\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"table = pd.read_sql_query(\"SELECT * from Earthquakes\", connection)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Part 1 and Part 2"
]
},
{
"cell_type": "cod
e",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"placecounts = dict(table.place.value_counts(normalize=False))"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"regioncounts = dict(table.region.value_counts(normalize=False))"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"How many earthquake locations to show?20\n",
"\n",
"Top 20 earthquake places\n",
"Central California 417\n",
"Bonin Islands, Japan region 404\n",
"Albania 382\n",
"Northern California 375\n",
"Andreanof Islands, Aleutian Islands, Alaska 319\n",
"New Britain region, Papua New Guinea 277\n",
"Mount St. Helens area, Washington 259\n",
"Vanuatu 235\n",
"Fiji region 213\n",
"Hindu Kush region, Afghanistan 197\n",
"Taiwan region 149\n",
"Aegean Sea 141\n",
"Tonga 133\n",
"Czech Republic 128\n",
"France 123\n",
"northern Italy 115\n",
"offshore Northern California 99\n",
"Greece 96\n",
"southwestern Ryukyu Islands, Japan 95\n",
"south of the Fiji Islands 90\n",
"\n",
"Top 20 earthquake regions\n",
"California 1488\n",
"Japan 891\n",
"Alaska 666\n",
"Indonesia 604\n",
"Mexico 570\n",
"Papua New Guinea 477\n",
"Albania 382\n",
"Washington 340\n",
"Figi 311\n",
"Chile 249\n",
"Vanuatu 245\n",
"Greece 220\n",
"Afghanistan 202\n",
"Taiwan 198\n",
"Tonga 156\n",
"Italy 155\n",
"Philippines 154\n",
"Aegean Sea 141\n",
"France 139\n",
"Czech Republic 132\n"
]
}
],
"source": [
"howmany = int(input(\"How many earthquake locations to show?\"))\n",
"print ('\\nTop', howmany, 'earthquake places')\n",
"\n",
"x = sorted(placecounts, key=placecounts.get, reverse=True)\n",
"for k in x[:howmany]:\n",
" print(k, placecounts[k])\n",
" if placecounts[k] < 10 : break\n",
"\n",
"print('\\nTop',howmany,'earthquake regions')\n",
"x = sorted(regioncounts, key=regioncounts.get, reverse=True)\n",
"for k in x[:howmany]:\n",
" print(k, regioncounts[k])\n",
" if regioncounts[k] < 10 : break\n"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Basic Statistics\n"
]
}
],
"source": [
"print(\"\\nBasic Statistics\")"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Place that has the most earthquakes: Central California\n",
"Region that has the most earthquakes: California\n"
]
}
],
"source": [
"print (\"Place that has the most earthquakes: \", sorted(placecounts, key=placecounts.get, reverse=True)[0])\n",
"print (\"Region that has the most earthquakes: \", sorted(regioncounts, key=regioncounts.get, reverse=True)[0])"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"
idmagnitudetimedepthplacetitlefeltregion
0usp0002upb4.7051805038528033.000TongaM 4.7 - TongaNoneTonga
1usp0002upa4.5051805007532033.000central PeruM 4.5 - central PeruNonePeru
2usp0002up94.2051804854592010.000north of SvalbardM 4.2 - north of SvalbardNoneSvalbard
3ci1258442.555180476845705.73835km ESE of San Clemente Is. (SE tip), CAM 2.6 - 35km ESE of San Clemente Is. (SE tip), CANoneCalifornia
4usp0002up84.7051804636412033.000Hindu Kush region, AfghanistanM 4.7 - Hindu Kush region, AfghanistanNoneAfghanistan
\n",
"
"
],
"text/plain": [
" id magnitude time depth \\\n",
"0 usp0002upb 4.70 518050385280 33.000 \n",
"1 usp0002upa 4.50 518050075320 33.000 \n",
"2 usp0002up9 4.20 518048545920 10.000 \n",
"3 ci125844 2.55 518047684570 5.738 \n",
"4 usp0002up8 4.70 518046364120 33.000 \n",
"\n",
" place \\\n",
"0 Tonga \n",
"1 central Peru \n",
"2 north of Svalbard \n",
"3 35km ESE of San Clemente Is. (SE tip), CA \n",
"4 Hindu Kush region, Afghanistan \n",
"\n",
" title felt region \n",
"0 M 4.7 - Tonga None Tonga \n",
"1 M 4.5 - central Peru None Peru \n",
"2 M 4.2 - north of Svalbard None Svalbard \n",
"3 M 2.6 - 35km ESE of San Clemente Is. (SE tip), CA None California \n",
"4 M 4.7 - Hindu Kush region, Afghanistan None Afghanistan "
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"table.head()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np \n",
"felt = np.array(table.felt)\n",
"depth = np.array(table.depth)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"magnitude = np.array(table.magnitude)\n"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"feltMagnitude = magnitude[depth > 50]"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Number of felt earthquakes: 2162\n"
]
}
],
"source": [
"print (\"Number of felt earthquakes: \", feltMagnitude.shape[0])"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Mean felt earthquake: 4.709532839962996\n"
]
}
],
"source": [
"print (\"Mean felt earthquake: \", np.mean(feltMagnitude))"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Biggest Earthquake, 7.4\n"
]
}
],
"source": [
"print (\"Biggest Earthquake, \", max(feltMagnitude))"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"import seaborn as sns\n",
"sns.set()\n"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
"placecountsdf = pd.DataFrame().from_records([\n",
" {\n",
" 'place': key,\n",
" 'count': placecounts[key]\n",
" } for key in placecounts\n",
"])"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"image/png":...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here