<jupyter_start><jupyter_text>"Risks by State"> "subtitles"- toc: true- math: true- badges: false<jupyter_code>#hide_input

import altair as alt
from vega_datasets import data
import pandas as pd

root = "C:\\Users\\julie\\Documents\\GitHub\\test-blog\\input_data\\covid_input\\regional_effects\\"


data_states = pd.read_excel(root + "regional_effects.xlsx", sheet_name='Sheet1')
states = alt.topo_feature(data.us_10m.url, 'states')
source_df = pd.read_json(data.income.url)


# add State id

data_states['id'] = [source_df[source_df.name == data_states.State[i]].id.values[0] for i in data_states.index.tolist()]
data_states = data_states.melt(['State','State abbreviation','id'], var_name='risk_type', value_name='pct')
#hide_input
alt.Chart(data_states).mark_geoshape().encode(
    shape='geo:G',
    color='pct:Q',
    tooltip=['State:N', alt.Tooltip('pct:Q', format='.2%')],
    facet=alt.Facet('risk_type:N', columns=1),
).transform_lookup(
    lookup='id',
    from_=alt.LookupData(data=states, key='id'),
    as_='geo'
).properties(
    width=600,
    height=300,
).project(
    type='albersUsa'
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17709251101321585, 'fraction_numerical': 0.010572687224669603, 'mean_word_length': 5.643274853801169, 'pattern_counts': {'":': 0, '<': 5, '<?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': '65831', 'license': 'Apache-2.0', 'n_tokens_mistral': 453, 'n_tokens_neox': 434, 'n_words': 68, 'path': '_notebooks/2020-04-27-test_chloropeth.ipynb', 'repo_name': 'julienduranton/test-blog', 'size': '1135'}