<jupyter_start><jupyter_text>_Lambda School Data Science_ Sequence your narrativeCreate a sequence of visualizations inspired by [<NAME>'s 200 Countries, 200 Years, 4 Minutes](https://www.youtube.com/watch?v=jbkSRLYSojo).Using this [data from Gapminder](https://github.com/open-numbers/ddf--gapminder--systema_globalis/):- https://raw.githubusercontent.com/open-numbers/ddf--gapminder--systema_globalis/master/ddf--datapoints--income_per_person_gdppercapita_ppp_inflation_adjusted--by--geo--time.csv- https://raw.githubusercontent.com/open-numbers/ddf--gapminder--systema_globalis/master/ddf--datapoints--life_expectancy_years--by--geo--time.csv-https://raw.githubusercontent.com/open-numbers/ddf--gapminder--systema_globalis/master/ddf--datapoints--population_total--by--geo--time.csv- https://raw.githubusercontent.com/open-numbers/ddf--gapminder--systema_globalis/master/ddf--entities--geo--country.csv- https://raw.githubusercontent.com/open-numbers/ddf--gapminder--systema_globalis/master/ddf--concepts.csv Stretch goals- [ipywidgets](https://github.com/jupyter-widgets/ipywidgets)- [Matplotlib animation](https://matplotlib.org/examples/animation/index.html)- [Connected scatter plots](http://www.thefunctionalart.com/2012/09/in-praise-of-connected-scatter-plots.html)- [Idyll markup language](https://idyll-lang.org/) for "scrollytelling"<jupyter_code>%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

income = pd.read_csv('https://raw.githubusercontent.com/open-numbers/ddf--gapminder--systema_globalis/master/ddf--datapoints--income_per_person_gdppercapita_ppp_inflation_adjusted--by--geo--time.csv')
lifespan = pd.read_csv('https://raw.githubusercontent.com/open-numbers/ddf--gapminder--systema_globalis/master/ddf--datapoints--life_expectancy_years--by--geo--time.csv')
population = pd.read_csv('https://raw.githubusercontent.com/open-numbers/ddf--gapminder--systema_globalis/master/ddf--datapoints--population_total--by--geo--time.csv')
entities = pd.read_csv('https://raw.githubusercontent.com/open-numbers/ddf--gapminder--systema_globalis/master/ddf--entities--geo--country.csv')
concepts = pd.read_csv('https://raw.githubusercontent.com/open-numbers/ddf--gapminder--systema_globalis/master/ddf--concepts.csv')

df = pd.merge(income, lifespan)
variables = ['country', 'name', 'world_4region']
entities[variables].head()
df = pd.merge(df, population)
df = pd.merge(df, entities[variables], 
              how='inner', left_on='geo', right_on='country')

df.drop(columns=['geo', 'country'], inplace=True)

df.rename(columns={
    'time': 'year', 
    'income_per_person_gdppercapita_ppp_inflation_adjusted': 'income', 
    'life_expectancy_years': 'lifespan', 
    'population_total': 'population', 
    'name': 'country', 
    'world_4region': 'region'
}, inplace=True)

df.shape
import altair as alt
now = df[df.year==2018]

alt.Chart(now).mark_point(
    opacity=0.8,
).encode(
    alt.X('income:Q',
        scale=alt.Scale(type='log',zero=False,base = 2)),
    alt.Y('lifespan:Q',
          scale=alt.Scale(zero=False)),
    color='region',
    size = 'population:Q',
    tooltip = ('country', 'income', 'lifespan','population'),
).properties(
    width=960,
    height=490
).interactive()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16788766788766787, 'fraction_numerical': 0.008547008547008548, 'mean_word_length': 5.125233644859813, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 15, 'lorem ipsum': 0, 'www.': 2, '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': '433260', 'license': 'MIT', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1132, 'n_words': 124, 'path': 'module4-sequence-your-narrative/LS_DS_124_Sequence_your_narrative.ipynb', 'repo_name': 'chrisseiler96/DS-Sprint-02-Storytelling-With-Data', 'size': '3282'}