<jupyter_start><jupyter_text>2) An update of the estimated number of OY in South King County<jupyter_code>%matplotlib inline
import pandas as pd

!pwd<jupyter_output>/Users/soledadmusella/Documents/mod_1_project/opportunity_youth/notebooks<jupyter_text>- We saved the query as a csv file and we loaded into a Jupyter Notebook- We noticed that the SQL query gave a few cities outside Washington. In order to fix this, we filtered the dataframe using state_fips as 53, which is the id for Washinton- We filtered the table by the range of age required( 16-24) in order to be included into the Opportunity Youth.- We filtered the result throught the employment status that matches the requirements of the Oportunity Youth.- We found an update of the estimated number of OY in South King County that equals 391.<jupyter_code>df_was = pd.read_csv("qquery.csv")
df_was.head()
df_was[df_was["state_fips"]==53]["puma"].unique()

df_was2=pd.read_csv("ws_rm.csv")
df_was2.head()
df_was2.shape
df_age = df_was2[(df_was2["agep"] >= 16) & (df_was2["agep"] <= 24)]
df_work = df_age[((df_age["esr"] == 3) | (df_age["esr"] == 6)) & (df_age["sch"] == 1)]
df_work.head()
df_work.shape[0]<jupyter_output><empty_output><jupyter_text>2.2) Breakdown by PUMA<jupyter_code>df_work.groupby(["puma"])['serialno'].nunique().reset_index()<jupyter_output><empty_output><jupyter_text>3)“Opportunity Youth Status by Age” 1 st TABLE<jupyter_code>dfq3 = pd.read_csv('../data/processed/question_3_base.csv')
dfq3.head()<jupyter_output><empty_output><jupyter_text>convert age column into 3 categories : 16-18, 19-21, 22-24<jupyter_code>dfq3['age_category'] = pd.cut(dfq3["agep"], [15, 18, 21, 24], labels=['16-18',"19-21","22-24"])
dfq3.head()<jupyter_output><empty_output><jupyter_text>Total Population<jupyter_code>df_tot = dfq3.groupby(["age_category"])["serialno"].nunique()
df_tot
tot_pop = print('Total: ', dfq3.groupby(["age_category"])["serialno"].nunique().sum() )<jupyter_output>Total:  2682<jupyter_text>Opportunity Youth<jupyter_code>dfq3_oy = dfq3[(dfq3["sch"] == 1) & (dfq3["esr"] == 3) | (dfq3["esr"] == 6)]
dfq3_oy.head()
tot_oy = dfq3_oy.groupby(["age_category"])["serialno"].nunique()
tot_oy
print('Total: ', dfq3_oy.groupby(["age_category"])["serialno"].nunique().sum() )<jupyter_output>Total:  1183<jupyter_text>Not an opportunity youth<jupyter_code>df_n_o_y = df_tot - tot_oy
df_n_o_y
print ("Total :", df_n_o_y .sum())<jupyter_output>Total : 1499<jupyter_text>Working whithout diploma<jupyter_code>dfq3_wwd = dfq3[(dfq3["schl"] >= 1) & (dfq3["schl"] <= 15) & (dfq3["esr"].isin([1,2,4,5]))]
dfq3_wwd.head()
dfq3_wwd.groupby(["age_category"])["serialno"].nunique()
print('Total: ', dfq3_wwd.groupby(["age_category"])["serialno"].nunique().sum() )<jupyter_output>Total:  235<jupyter_text>FINAL TABLE<jupyter_code>pd.DataFrame({'16-18':[557, 124, 288],'19-21':[422,61, 615],'22-24':[204,50,596], 'Total':[1183,235,1499]}, index=['Opportunity Youth','Working Without Diploma','Not an Opportunity Youth'])<jupyter_output><empty_output><jupyter_text>3.1)“Opportunity Youth Status by Age” 2 TABLE No diploma<jupyter_code>dfq32 = dfq3[dfq3["schl"] <= 15]
dfq32.head()
tot_no_diploma = dfq32.groupby(["age_category"])["serialno"].nunique()
tot_no_diploma
print('Total: ', tot_no_diploma.sum() )<jupyter_output>Total:  821<jupyter_text>HS diploma or GED<jupyter_code>dfq33 = dfq3[(dfq3["schl"] == 16) | (dfq3["schl"] == 17)]
dfq33.head()
tot_hs_ged = dfq33.groupby(["age_category"])["serialno"].nunique()
tot_hs_ged
print('Total: ', tot_hs_ged.sum() )<jupyter_output>Total:  730<jupyter_text>Some college, no degree<jupyter_code>dfq34 = dfq3[(dfq3["schl"] == 18) | (dfq3["schl"] == 19)]
dfq34.head()
some_college = dfq34.groupby(["age_category"])["serialno"].nunique()
some_college
print('Total: ', some_college.sum() )<jupyter_output>Total:  853<jupyter_text>Degree(Associate or higher)<jupyter_code>dfq35 = dfq3[(dfq3["schl"] == 20) | (dfq3["schl"] == 21) | (dfq3["schl"] == 22) | 
             (dfq3["schl"] == 23) | (dfq3["schl"] == 24)]
dfq35.head()
degree = dfq35.groupby(["age_category"])["serialno"].nunique()
degree
print('Total: ', degree.sum() )<jupyter_output>Total:  407<jupyter_text>FINAL TABLE<jupyter_code>pd.DataFrame({'16-18':[592, 148, 114, 9],'19-21':[146,335, 477,119],'22-24':[83,227,262,279], 'Total':[821,730,853,407]}, index=['No Diploma','HS diploma or GED','Some College, no Degree','Degree( Associate or Higher)'])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18551832696199685, 'fraction_numerical': 0.06543737351023161, 'mean_word_length': 8.152263374485596, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 54, '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': '15', 'dir': 'jupyter-structured-clean-dedup', 'id': '288454', 'license': 'MIT', 'n_tokens_mistral': 2007, 'n_tokens_neox': 1810, 'n_words': 309, 'path': 'notebooks/Updated number of OY in South King County.ipynb', 'repo_name': 'soledadmusella/opportunity_youth', 'size': '4447'}