<jupyter_start><jupyter_text>Abgespeckte Version des Clusterings<jupyter_code>import pandas as pd
import numpy as np
import plotly.express as px
import plotly.graph_objects as go
import json<jupyter_output><empty_output><jupyter_text>Preparing<jupyter_code>clusters = pd.read_csv("clustering.csv")
european_union = json.load(open("european-union-countries.geojson", "r"))
state_id_map = {}
for feature in european_union["features"]:
    feature["id"] = feature["properties"]["gu_a3"]
    state_id_map[feature["properties"]["name_long"]] = feature["id"]
    
clusters["id"] = clusters["Country"].apply(lambda x: state_id_map[x])
clusters.to_csv("final_clusters.csv")<jupyter_output><empty_output><jupyter_text>Food<jupyter_code>fig = px.choropleth_mapbox(
    clusters,
    locations="id",
    geojson=european_union,
    color="cluster_food",
    hover_name="Country",
    #hover_data=["Life Expectancy"],
    title="clusters by food",
    mapbox_style="carto-positron", 
    center={"lat": 56.5, "lon": 11},
    zoom=2.5,
    opacity=0.7, 
    height=600,
    width=550
)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})

fig.show()<jupyter_output><empty_output><jupyter_text>Overall (Food+Health)<jupyter_code>fig = px.choropleth_mapbox(
    clusters,
    locations="id",
    geojson=european_union,
    color="cluster_total",
    hover_name="Country",
    hover_data=["Life Expectancy"],
    title="Clusters by health",
    mapbox_style="carto-positron", 
    center={"lat": 56.5, "lon": 11},
    zoom=2.5,
    opacity=0.7, 
    height=600,
    width=550
)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})

fig.show()
clusters
path = 'https://raw.githubusercontent.com/FranzMichaelFrank/health_eu/main/'

def cz(s):
    if s == "Czech Republic":
        return "Czechia"
    else:
        return s
    
clusters["Country"] = clusters["Country"].apply(cz)
df_scatter = pd.read_csv(path + 'scatter_data.csv', dtype={"id": str})
box_cluster = df_scatter.merge(clusters[["Country","cluster_food","cluster_health","cluster_total"]], on="Country")
box_cluster = box_cluster.rename(columns={"cluster_food":"Food", "cluster_health":"Health", "cluster_total":"Food & Health"})
box_cluster.to_csv("box_cluster.csv")
clusts = ["Food", "Health", "Food & Health"]

ots = ["Alcoholic Beverages", "Animal fats", "Cereals - Excluding Beer", "Eggs", 
                "Fish, Seafood", "Fruits - Excluding Wine", "Meat", "Milk - Excluding Butter",
                "Offals", "Oilcrops", "Pulses", "Spices", "Starchy Roots","Stimulants", 
                "Sugar & Sweeteners", "Treenuts", "Vegetable Oils",
                "Vegetables","Obesity", "Diabetes Prevalence", "Cardiovascular Death Rate", "Life Expectancy", "Health Expenditure" ]
import plotly.express as px



li = [, '#46039f', , '#9c179e', , '#d8576b', , '#fb9f3a', , '#f0f921'].reverse()
li
['#fdca26', '#ed7953', '#bd3786', '#7201a8', '#0d0887']<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17753499487879823, 'fraction_numerical': 0.026630249231819735, 'mean_word_length': 5.168421052631579, 'pattern_counts': {'":': 17, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 1, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '266090', 'license': 'MIT', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1070, 'n_words': 174, 'path': 'apps/dash-food-consumption/notebooks/clustering_poster.ipynb', 'repo_name': 'Erfard/dash-sample-apps', 'size': '2929'}