<jupyter_start><jupyter_text><jupyter_code>!pip install davos
import davos
smuggle numpy as np
smuggle pandas as pd
smuggle plotly 
from plotly import express as px
df = pd.read_csv('https://raw.githubusercontent.com/ContextLab/storytelling-with-data/master/data-stories/VT-DoH/Impact%20of%20pandemic%20on%20emergent%20case%20numbers.csv')
df['Question'] = pd.DataFrame(df['Question']).ffill()['Question']
df.head()
perquestion = [df.query(f'Question == "{q}"') for q in np.unique(df['Question'])]
perquestion[1]
figs = [px.pie(perquestion[i], values='n ', names='answer', title=perquestion[i].iloc[0]['Question']) for i in range(len(perquestion))]
figs[0]
figs[1]
figs[2]
figs[3]
reduction_max= pd.read_csv('https://github.com/FanruiShao/storytelling-with-data/raw/master/data-stories/VT-DoH/loss_spending.csv')
reduction_max
import plotly.express as px

fig = px.bar(reduction_max, x='specialty', y='actual spending', title='in $millions')
fig.show()
import plotly.express as px

fig = px.bar(reduction_max, x='specialty', y='expected spending')
fig.show()
df = pd.concat([reduction_max, reduction_max.copy()], axis=0).reset_index()
df ['spending in $millions'] = 0
df ['medicare specialty'] = ''
df
df.loc[0:2]['spending in $millions'] = df.loc[0:2]['expected spending']
df.loc[3:]['spending in $millions'] = df.loc[3:]['actual spending']

df.loc[0:2]['medicare specialty'] = 'expected'
df.loc[3:]['medicare specialty'] = 'actual'

df
px.bar(data_frame=df, x= 'specialty', y='spending in $millions',color='medicare specialty', barmode='group')
state_drop = pd.read_csv('https://github.com/FanruiShao/storytelling-with-data/raw/master/data-stories/VT-DoH/state_drop.csv')
state_drop
px.bar(data_frame=state_drop, x= 'state', y='percentage drop(%)', color = 'actual spending ($millions)',  hover_name = 'percentage drop(%)' , title ='cumulative reduction in MPFS Spending, 2020')
df = pd.concat([state_drop, state_drop.copy()], axis=0).reset_index()
df ['spending($millions)'] = 0
df ['type'] = ''
df
df.loc[0:5]['spending($millions)'] = df.loc[0:5]['expected spending ($millions)']
df.loc[6:]['spending($millions)'] = df.loc[6:]['actual spending ($millions)']

df.loc[0:5]['type'] = 'expected'
df.loc[6:]['type'] = 'actual'

df
px.bar(data_frame = df, x = 'state', y = 'spending($millions)',color='type', barmode='group', title = 'MPFS Spending, 2020')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19756711409395974, 'fraction_numerical': 0.020134228187919462, 'mean_word_length': 7.28125, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 3, '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': '197744', 'license': 'MIT', 'n_tokens_mistral': 926, 'n_tokens_neox': 894, 'n_words': 166, 'path': 'data-stories/VT-DoH/fanrui/ignored_treatment.ipynb', 'repo_name': 'BohanMeng/storytelling-with-data', 'size': '2384'}