<jupyter_start><jupyter_text>Table of Contents<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt
import os
%matplotlib inline
os.chdir(r"C:\Users\<NAME>\OneDrive - Hochschule Luzern\01 Studium\03 MSc Data Science\Master FS20\Wahlpflichtmodule\W.MSCIDS_DVN03.F2001\LNW2")
from preprocessing.functions.data_helper import DataHelper
from preprocessing.functions.data_formatter import DataFormatter
import geopandas as gpd
# prepare geopandas
shapefile = './data/data_countries/ne_10m_admin_0_countries.shp'
gdf = gpd.read_file(shapefile)[['ADMIN', 'ADM0_A3', 'geometry']]
gdf.columns = ['country', 'country_code', 'geometry']
gdf = gdf[gdf['country'] != 'Antarctica']

# prepare shark data
data_helper = DataHelper()
data_formatter = DataFormatter()
df = data_helper.data_categorized
df = df[df["year"].between(1999, 2019)]

df.columns
cols = ['case_number', 'date_prep', 'year_prep', 'type', 'country', 'area', 'location',
       'activity_cat', 'sex', 'age_prep', 'injury_cat', 'fatal(y/n)', 'time',
       'species_cat', 'activity_cat']
df = df[cols]
# merge data
df_merged = gdf.merge(df, left_on="country", right_on="country")

import json
df_merged = json.loads(df_merged.to_json())
json_data = json.dumps(df_merged)
df
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world
fig, ax = plt.subplots(figsize=(20,10))
world.plot(ax=ax, "gdp_md_est")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14720452937013448, 'fraction_numerical': 0.021231422505307854, 'mean_word_length': 7.034090909090909, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '528940', 'license': 'MIT', 'n_tokens_mistral': 562, 'n_tokens_neox': 522, 'n_words': 101, 'path': 'visualisation/sharks_visualisation.ipynb', 'repo_name': 'andygubser/data_visualisation', 'size': '1418'}