Skip to content

Commit

Permalink
🇬🇧🇮🇪 Add Swim NI discoveries
Browse files Browse the repository at this point in the history
  • Loading branch information
leonmelein committed Feb 20, 2024
1 parent 18b5bbf commit d08102c
Show file tree
Hide file tree
Showing 2 changed files with 198 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ __pycache__/
.ipynb_checkpoints/
.ssl/
data/countries/dataset.sqlite3
env/
env/
.zed/
196 changes: 196 additions & 0 deletions data/united_kingdom/UK-SwimNI.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import pandas as pd\n",
"import sqlite3"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"server = \"https://euswimapp.com/api/v1/beaches\""
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"data = requests.get(server, headers={\"Accept\": \"application/json, text/javascript, */*; q=0.01\"})\n",
"result = data.json()['beaches']"
]
},
{
"cell_type": "code",
"execution_count": 8,
"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>name</th>\n",
" <th>temperature</th>\n",
" <th>location.latitude</th>\n",
" <th>location.longitude</th>\n",
" <th>water_quality.classification</th>\n",
" <th>water_quality.timestamp</th>\n",
" </tr>\n",
" <tr>\n",
" <th>id</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Ballyholme Beach</td>\n",
" <td>None</td>\n",
" <td>54.668352</td>\n",
" <td>-5.637678</td>\n",
" <td>Excellent</td>\n",
" <td>2024-02-20T08:01:50+00:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Ballywalter Beach</td>\n",
" <td>None</td>\n",
" <td>54.544500</td>\n",
" <td>-5.482600</td>\n",
" <td>Excellent</td>\n",
" <td>2024-02-20T08:01:57+00:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Castlerock Beach</td>\n",
" <td>None</td>\n",
" <td>55.168300</td>\n",
" <td>-6.786300</td>\n",
" <td>Excellent</td>\n",
" <td>2024-02-20T08:02:02+00:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Newcastle Beach</td>\n",
" <td>None</td>\n",
" <td>54.213400</td>\n",
" <td>-5.886071</td>\n",
" <td>Excellent</td>\n",
" <td>2024-02-20T08:02:07+00:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Portrush East/Curran Strand Beach</td>\n",
" <td>None</td>\n",
" <td>55.205100</td>\n",
" <td>-6.645800</td>\n",
" <td>Excellent</td>\n",
" <td>2024-02-20T08:02:12+00:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Waterfoot Beach</td>\n",
" <td>None</td>\n",
" <td>55.060859</td>\n",
" <td>-6.054550</td>\n",
" <td>Excellent</td>\n",
" <td>2024-02-20T08:02:18+00:00</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" name temperature location.latitude \\\n",
"id \n",
"4 Ballyholme Beach None 54.668352 \n",
"5 Ballywalter Beach None 54.544500 \n",
"1 Castlerock Beach None 55.168300 \n",
"6 Newcastle Beach None 54.213400 \n",
"2 Portrush East/Curran Strand Beach None 55.205100 \n",
"3 Waterfoot Beach None 55.060859 \n",
"\n",
" location.longitude water_quality.classification water_quality.timestamp \n",
"id \n",
"4 -5.637678 Excellent 2024-02-20T08:01:50+00:00 \n",
"5 -5.482600 Excellent 2024-02-20T08:01:57+00:00 \n",
"1 -6.786300 Excellent 2024-02-20T08:02:02+00:00 \n",
"6 -5.886071 Excellent 2024-02-20T08:02:07+00:00 \n",
"2 -6.645800 Excellent 2024-02-20T08:02:12+00:00 \n",
"3 -6.054550 Excellent 2024-02-20T08:02:18+00:00 "
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = pd.json_normalize(result)\\\n",
" .set_index('id')\\\n",
" .drop(columns=['address', 'image'])\n",
"df"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "env",
"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.12.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit d08102c

Please sign in to comment.