<jupyter_start><jupyter_text>Make line plot for app<jupyter_code>%load_ext autoreload
%autoreload 2
import pandas as pd
index_vars = ['location_name', 'year_id']
df = pd.read_csv('../data/processed/GBD_child_health_indicators.csv')
location_metadata = pd.read_csv('../data/metadata/gbd_location_metadata.csv')
df_wide = df.pivot_table(index=['location_name', 'year_id'], columns='indicator', values='val').reset_index()
df_wide = pd.merge(location_metadata, df_wide)
df_wide.head()
import plotly.plotly as py
import plotly.graph_objs as go
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
# Connect Javascript to display the plots in the notebook
init_notebook_mode(connected=True)
# For one country, plot all indicators
df_l = df.query('location_id == 6')
data = [
            go.Scatter(
                x=df_l[df_l['indicator'] == i]['year_id'],
                y=df_l[df_l['indicator'] == i]['val'],
                # text=df_l[df_l['location_id'] == i]['location_name'],
                mode='lines+markers',
                opacity=0.7,
                marker={
                    'size': 10,
                    # 'color': dif_similar[dif_similar['cluster'] == i]['color'],  # palette[i],
                    'line': {'width': 0.5, 'color': 'white'}
                },
                name=str(i)
            ) for i in df_l.indicator.unique()
        ]
layout = go.Layout(
            # title=f'Difference between {loc_id} and similar countries',
            xaxis={'title': 'Index Value'},
#             yaxis={'title': 'test'},
             height=500,
            margin={'l': 120, 'b': 40, 't': 40, 'r': 0},
            hovermode='closest')
fig = dict(data=data, layout=layout)

# iplot(data)
iplot(fig)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15098591549295776, 'fraction_numerical': 0.010704225352112675, 'mean_word_length': 2.811158798283262, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '81636', 'license': 'MIT', 'n_tokens_mistral': 605, 'n_tokens_neox': 571, 'n_words': 117, 'path': 'notebooks/_archive/2019_02_07_indicator_time_series_plot.ipynb', 'repo_name': 'zwrankin/health_indicators', 'size': '1775'}