# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
import pandas as pd
import numpy as np

unemp_county = pd.read_csv("datasets/us_unemployment.csv")
unemp_county.head()

# +
df = pd.read_csv("datasets/minwage.csv")

act_min_wage = pd.DataFrame()

for name, group in df.groupby("State"):
    if act_min_wage.empty:
        act_min_wage = group.set_index("Year")[["Low.2018"]].rename(columns={"Low.2018": name})
    else:
        act_min_wage = act_min_wage.join(group.set_index("Year")[["Low.2018"]].rename(columns={"Low.2018": name}))

act_min_wage.head()
# -

act_min_wage = act_min_wage.replace(0, np.NaN).dropna(axis=1)
act_min_wage.head()


# +
def get_min_wage(year, state):
    try:
        return act_min_wage.loc[year][state]
    except:
        return np.NaN
    
get_min_wage(2012, "Colorado")

# +
# %%time

unemp_county['min_wage'] = list(map(get_min_wage, unemp_county['Year'], unemp_county["State"]))
# -

unemp_county.head()

unemp_county[["Rate", "min_wage"]].corr()

unemp_county[["Rate", "min_wage"]].cov()

pres16 = pd.read_csv("datasets/pres16results.csv")
pres16.head()

county_2015 = unemp_county[(unemp_county['Year'] == 2015) & (unemp_county['Month']=='February')]







StarcoderdataJupyterScriptsDedupFiltered