Analysis by Jason Muteham
Photo by Jason Muteham
Questions answered in this report
This notebook analyses the wrangled data created in the notebook HWDT Data Wrangle.ipynb
Hebridean Whale and Dolphin Trust
Based on the Isle of Mull, in the heart of the Hebrides, HWDT has been leading the way for the conservation of whales, dolphins and porpoises in the waters of western Scotland for over two decades.
We believe evidence is the foundation of effective conservation. Our research has critically advanced the understanding of species that visit seasonally or are resident in the Hebrides. Data are provided to the Scottish Government to inform protection measures for minke whales, Risso’s dolphins, harbour porpoises, and basking sharks across Hebridean seas.
Data provided by the following providers:
Imports
#%%capture
#!pip install OSGridConverter
import pandas as pd
import plotly.express as px
import plotly.io as pio
import plotly.figure_factory as ff
from OSGridConverter import grid2latlong
pio.renderers.default = "vscode+notebook"
Parameter setup
Constants
import_file = 'Data/export-2022.csv'
name = "Basking Shark"
# Which OS bins to use for the maps
ll_OSGbin = 'OSG 1km'
#"open-street-map", "carto-positron", "carto-darkmatter", "stamen-terrain", "stamen-toner" or "stamen-watercolor"
px_map_tiles = 'carto-darkmatter'
mg = dict(l=20, r=20, b=20, t=100)
Fuctions
# Create df group by OSGbin
def OSGbiner(OSGbin):
df_tmp = dw.groupby([OSGbin,'Common name'])['Individual count'].sum()
df_tmp = df_tmp.reset_index()
df_tmp = df_tmp.pivot_table(index=OSGbin, values='Individual count', columns='Common name')
df_tmp = df_tmp.fillna(0)
df_tmp['Total'] = df_tmp.agg('sum', axis=1)
df_tmp = df_tmp.sort_values(by='Total')
return df_tmp
Import Data
dw = pd.read_csv(import_file, parse_dates=["Date"])
fig = px.bar(dw.query('`Common name` == "Basking Shark"').groupby('Date year')['Individual count'].agg('sum'),
y='Individual count', title= 'The number of ' + name + "s spotted each year", text_auto=True, height=500,)
fig.update_layout(yaxis_title='Count of ' + name + 's', xaxis_title='', showlegend=False)
fig.update_traces(hovertemplate=' Year %{x}, %{y} spotted',marker_line_color='darkgreen', marker_line_width=1.0)
fig.show()