import%20marimo%0A%0A__generated_with%20%3D%20%220.23.9%22%0Aapp%20%3D%20marimo.App(width%3D%22medium%22)%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%20Tampa%E2%80%93St.%20Petersburg%20labor-force%20portrait%20(OEWS)%0A%0A%20%20%20%20What%20the%20metro%20does%20for%20work%2C%20what%20it%20pays%2C%20and%20what%20it%20specializes%20in%20%E2%80%94%20the%20full%20occupational%0A%20%20%20%20structure%20(22%20SOC%20major%20groups)%20for%20the%20Tampa%E2%80%93St.%20Pete%E2%80%93Clearwater%20MSA%20vs%20the%20U.S.%2C%20from%20BLS%0A%20%20%20%20OEWS%20(2025).%20**Workplace-based**%20(jobs%20located%20here)%2C%20**MSA-grain**%20(not%20the%20city%20%E2%80%94%20that's%20the%0A%20%20%20%20ACS%20layer)%2C%20a%20point-in-time%20snapshot%20(OEWS%20is%20not%20a%20time%20series).%20Source%3A%20%60scripts%2Fingest_oews.py%60%0A%20%20%20%20%C2%B7%20dossier%3A%20%60docs%2Fpipelines%2Foews.md%60.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20from%20pathlib%20import%20Path%0A%20%20%20%20import%20duckdb%0A%20%20%20%20import%20marimo%20as%20mo%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20import%20pandas%20as%20pd%0A%20%20%20%20import%20matplotlib.pyplot%20as%20plt%0A%0A%20%20%20%20return%20Path%2C%20duckdb%2C%20mo%2C%20pd%2C%20plt%0A%0A%0A%40app.cell%0Adef%20_(Path%2C%20duckdb)%3A%0A%20%20%20%20def%20_find_db()%3A%0A%20%20%20%20%20%20%20%20for%20d%20in%20%5BPath.cwd()%2C%20*Path.cwd().parents%5D%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(d%20%2F%20%22analytics.db%22).exists()%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20str(d%20%2F%20%22analytics.db%22)%0A%20%20%20%20%20%20%20%20raise%20FileNotFoundError(%22analytics.db%20not%20found%22)%0A%20%20%20%20conn%20%3D%20duckdb.connect(_find_db()%2C%20read_only%3DTrue)%0A%20%20%20%20def%20q(sql)%3A%0A%20%20%20%20%20%20%20%20return%20conn.execute(sql).fetchdf()%0A%0A%20%20%20%20return%20(q%2C)%0A%0A%0A%40app.cell%0Adef%20_(q)%3A%0A%20%20%20%20%23%20Major%20groups%20(22)%20for%20each%20area%2C%20the%20all-occ%20total%2C%20and%20detail%20drill-downs.%0A%20%20%20%20maj%20%3D%20q(%22%22%22SELECT%20soc_code%2C%20soc_title%2C%20tot_emp%2C%20emp_prse%2C%20a_mean%2C%20a_median%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20a_pct10%2C%20a_pct25%2C%20a_pct75%2C%20a_pct90%2C%20occ_lq_bls%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20FROM%20oews_occupation%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20WHERE%20area_fips%3D'0045300'%20AND%20soc_level%3D'major'%20ORDER%20BY%20tot_emp%20DESC%22%22%22)%0A%20%20%20%20majus%20%3D%20q(%22%22%22SELECT%20soc_code%2C%20a_mean%20AS%20us_a_mean%2C%20tot_emp%20AS%20us_tot_emp%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20FROM%20oews_occupation%20WHERE%20area_fips%3D'0000000'%20AND%20soc_level%3D'major'%22%22%22)%0A%20%20%20%20detail%20%3D%20q(%22%22%22SELECT%20soc_code%2C%20soc_title%2C%20tot_emp%2C%20a_median%2C%20a_pct10%2C%20a_pct90%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20FROM%20oews_occupation%20WHERE%20area_fips%3D'0045300'%20AND%20soc_level%3D'detail'%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ORDER%20BY%20tot_emp%20DESC%22%22%22)%0A%20%20%20%20total_emp%20%3D%20q(%22%22%22SELECT%20tot_emp%20FROM%20oews_occupation%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20WHERE%20area_fips%3D'0045300'%20AND%20soc_code%3D'00-0000'%22%22%22).iloc%5B0%5D.tot_emp%0A%20%20%20%20return%20detail%2C%20maj%2C%20majus%2C%20total_emp%0A%0A%0A%40app.cell%0Adef%20_(maj%2C%20mo%2C%20total_emp)%3A%0A%20%20%20%20_top%20%3D%20maj.iloc%5B0%5D%0A%20%20%20%20_tech%20%3D%20maj%5Bmaj.soc_code%20%3D%3D%20%2215-0000%22%5D.iloc%5B0%5D%0A%20%20%20%20_majr%20%3D%20maj.reset_index(drop%3DTrue)%20%20%23%20maj%20is%20ordered%20by%20employment%20desc%0A%20%20%20%20_tech_rank%20%3D%20int(_majr.index%5B_majr.soc_code%20%3D%3D%20%2215-0000%22%5D%5B0%5D)%20%2B%201%0A%20%20%20%20mo.md(f%22%22%22%0A%20%20%20%20%23%23%201%20%C2%B7%20The%20shape%20of%20the%20job%20base%0A%0A%20%20%20%20The%20Tampa%E2%80%93St.%20Pete%20metro%20supports%20**%7Bint(total_emp)%3A%2C%7D**%20jobs.%20The%20largest%20occupation%20group%20is%0A%20%20%20%20**%7B_top.soc_title%7D**%20(%7Bint(_top.tot_emp)%3A%2C%7D).%20Computer%20%26%20Mathematical%20work%20is%0A%20%20%20%20**%7Bint(_tech.tot_emp)%3A%2C%7D**%20jobs%20%E2%80%94%20the%20**%23%7B_tech_rank%7D**%20largest%20of%20the%2022%20groups%2C%20mid-pack%20among%0A%20%20%20%20everyday%20occupations%2C%20not%20a%20dominant%20sector.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(maj%2C%20plt)%3A%0A%20%20%20%20_d%20%3D%20maj.sort_values(%22tot_emp%22)%0A%20%20%20%20_fig%2C%20_ax%20%3D%20plt.subplots(figsize%3D(9%2C%208))%0A%20%20%20%20_colors%20%3D%20%5B%22%23C44E52%22%20if%20c%20%3D%3D%20%2215-0000%22%20else%20%22%234C72B0%22%20for%20c%20in%20_d.soc_code%5D%0A%20%20%20%20_ax.barh(_d.soc_title%2C%20_d.tot_emp%2C%20color%3D_colors)%0A%20%20%20%20_ax.set_title(%22Employment%20by%20occupation%20group%20%E2%80%94%20Tampa%E2%80%93St.%20Pete%20MSA%20(2025)%22)%0A%20%20%20%20_ax.set_xlabel(%22employment%22)%3B%20_ax.grid(axis%3D%22x%22%2C%20alpha%3D0.3)%0A%20%20%20%20_fig.tight_layout()%0A%20%20%20%20_fig%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%202%20%C2%B7%20Wages%3A%20level%20and%20spread%0A%0A%20%20%20%20Annual%20pay%20by%20group%20%E2%80%94%20the%20bar%20spans%20the%2010th%E2%80%9390th%20percentile%2C%20the%20dot%20marks%20the%20median.%20Groups%0A%20%20%20%20are%20sorted%20by%20median%20wage%2C%20so%20the%20pay%20hierarchy%20and%20the%20within-occupation%20spread%20are%20both%20visible.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(maj%2C%20plt)%3A%0A%20%20%20%20_d%20%3D%20maj.dropna(subset%3D%5B%22a_median%22%2C%20%22a_pct10%22%2C%20%22a_pct90%22%5D).sort_values(%22a_median%22)%0A%20%20%20%20_y%20%3D%20range(len(_d))%0A%20%20%20%20_fig%2C%20_ax%20%3D%20plt.subplots(figsize%3D(9%2C%208))%0A%20%20%20%20_ax.hlines(list(_y)%2C%20_d.a_pct10%2C%20_d.a_pct90%2C%20color%3D%22%23B0B7C6%22%2C%20lw%3D4)%0A%20%20%20%20_ax.plot(_d.a_median%2C%20list(_y)%2C%20%22o%22%2C%20color%3D%22%23C44E52%22)%0A%20%20%20%20_ax.set_yticks(list(_y))%3B%20_ax.set_yticklabels(_d.soc_title)%0A%20%20%20%20_ax.set_title(%22Annual%20wage%3A%2010th%E2%80%9390th%20percentile%20(bar)%20and%20median%20(dot)%2C%20Tampa%E2%80%93St.%20Pete%20(2025)%22)%0A%20%20%20%20_ax.set_xlabel(%22annual%20wage%20(%24)%22)%3B%20_ax.grid(axis%3D%22x%22%2C%20alpha%3D0.3)%0A%20%20%20%20_fig.tight_layout()%0A%20%20%20%20_fig%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%203%20%C2%B7%20What%20the%20metro%20specializes%20in%0A%0A%20%20%20%20Location%20quotient%20vs%20the%20U.S.%20(%3E1%20%3D%20more%20concentrated%20here%20than%20nationally%2C%20%3C1%20%3D%20less).%20This%20is%0A%20%20%20%20what%20the%20local%20economy%20is%20actually%20built%20on.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(maj%2C%20plt)%3A%0A%20%20%20%20_d%20%3D%20maj.dropna(subset%3D%5B%22occ_lq_bls%22%5D).sort_values(%22occ_lq_bls%22)%0A%20%20%20%20_colors%20%3D%20%5B%22%2355A868%22%20if%20v%20%3E%3D%201%20else%20%22%23CC8963%22%20for%20v%20in%20_d.occ_lq_bls%5D%0A%20%20%20%20_fig%2C%20_ax%20%3D%20plt.subplots(figsize%3D(9%2C%208))%0A%20%20%20%20_ax.barh(_d.soc_title%2C%20_d.occ_lq_bls%2C%20color%3D_colors)%0A%20%20%20%20_ax.axvline(1.0%2C%20color%3D%22gray%22%2C%20lw%3D0.8%2C%20ls%3D%22--%22)%0A%20%20%20%20_ax.set_title(%22Occupational%20specialization%20%E2%80%94%20location%20quotient%20vs%20U.S.%20(Tampa%E2%80%93St.%20Pete%2C%202025)%22)%0A%20%20%20%20_ax.set_xlabel(%22location%20quotient%20(1.0%20%3D%20national%20average)%22)%3B%20_ax.grid(axis%3D%22x%22%2C%20alpha%3D0.3)%0A%20%20%20%20_fig.tight_layout()%0A%20%20%20%20_fig%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%204%20%C2%B7%20Local%20vs%20national%20pay%0A%0A%20%20%20%20For%20each%20group%2C%20the%20local%20mean%20wage%20divided%20by%20the%20national%20mean%20wage%20for%20the%20same%20occupation%20%E2%80%94%0A%20%20%20%20where%20the%20metro%20pays%20above%20(%3E1)%20or%20below%20(%3C1)%20the%20national%20rate.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(maj%2C%20majus%2C%20plt)%3A%0A%20%20%20%20_m%20%3D%20maj.merge(majus%2C%20on%3D%22soc_code%22)%0A%20%20%20%20_m%20%3D%20_m%5B(_m.a_mean.notna())%20%26%20(_m.us_a_mean.notna())%5D.copy()%0A%20%20%20%20_m%5B%22ratio%22%5D%20%3D%20_m.a_mean%20%2F%20_m.us_a_mean%0A%20%20%20%20_m%20%3D%20_m.sort_values(%22ratio%22)%0A%20%20%20%20_colors%20%3D%20%5B%22%2355A868%22%20if%20v%20%3E%3D%201%20else%20%22%23CC8963%22%20for%20v%20in%20_m.ratio%5D%0A%20%20%20%20_fig%2C%20_ax%20%3D%20plt.subplots(figsize%3D(9%2C%208))%0A%20%20%20%20_ax.barh(_m.soc_title%2C%20_m.ratio%2C%20color%3D_colors)%0A%20%20%20%20_ax.axvline(1.0%2C%20color%3D%22gray%22%2C%20lw%3D0.8%2C%20ls%3D%22--%22)%0A%20%20%20%20_ax.set_title(%22Local%20%C3%B7%20national%20mean%20wage%20by%20occupation%20(Tampa%E2%80%93St.%20Pete%2C%202025)%22)%0A%20%20%20%20_ax.set_xlabel(%22wage%20ratio%20(1.0%20%3D%20national%20parity)%22)%3B%20_ax.grid(axis%3D%22x%22%2C%20alpha%3D0.3)%0A%20%20%20%20_fig.tight_layout()%0A%20%20%20%20_fig%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(detail%2C%20mo%2C%20pd)%3A%0A%20%20%20%20_rows%20%3D%20%22%5Cn%22.join(%0A%20%20%20%20%20%20%20%20f%22%7C%20%7Br.soc_title%7D%20%7C%20%7Bint(r.tot_emp)%3A%2C%7D%20%7C%20%24%7Bint(r.a_median)%3A%2C%7D%20%7C%22%0A%20%20%20%20%20%20%20%20for%20r%20in%20detail.itertuples()%20if%20not%20pd.isna(r.tot_emp)%20and%20not%20pd.isna(r.a_median)%0A%20%20%20%20)%20if%20len(detail)%20else%20%22%22%0A%20%20%20%20mo.md(f%22%22%22%0A%20%20%20%20%23%23%20Detailed%20occupations%20(drill-down)%0A%0A%20%20%20%20%7C%20Occupation%20%7C%20Employment%20%7C%20Median%20wage%20%7C%0A%20%20%20%20%7C---%7C---%7C---%7C%0A%20%20%20%20%7B_rows%7D%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(maj%2C%20mo)%3A%0A%20%20%20%20_tech%20%3D%20maj%5Bmaj.soc_code%20%3D%3D%20%2215-0000%22%5D.iloc%5B0%5D%0A%20%20%20%20_n%20%3D%20len(maj)%0A%20%20%20%20_majr%20%3D%20maj.reset_index(drop%3DTrue)%20%20%23%20maj%20is%20ordered%20by%20employment%20desc%0A%20%20%20%20_rank%20%3D%20int(_majr.index%5B_majr.soc_code%20%3D%3D%20%2215-0000%22%5D%5B0%5D)%20%2B%201%0A%20%20%20%20mo.md(f%22%22%22%0A%20%20%20%20%23%23%20Tech%2C%20in%20context%0A%0A%20%20%20%20Computer%20%26%20Mathematical%20occupations%20are%20**%7Bint(_tech.tot_emp)%3A%2C%7D**%20jobs%20%E2%80%94%20the%20**%23%7B_rank%7D%20of%20%7B_n%7D**%0A%20%20%20%20occupation%20groups%20by%20employment%2C%20with%20a%20location%20quotient%20of%20**%7B_tech.occ_lq_bls%3A.2f%7D**%20(%E2%89%88%20the%20national%20average).%0A%20%20%20%20The%20recurring%20%22St.%20Pete%20tech%20grows%203%C3%97%20the%20national%20rate%22%20booster%20line%20%E2%80%94%20an%20unattributed%20claim%20%E2%80%94%0A%20%20%20%20doesn't%20survive%20contact%20with%20the%20occupation%20data%3A%20on%20concentration%2C%20tech%20sits%20at%20parity%2C%20one%0A%20%20%20%20ordinary%20group%20among%2022.%20It's%20a%20real%20part%20of%20the%20economy%2C%20not%20the%20story%20of%20it.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(q)%3A%0A%20%20%20%20acs%20%3D%20q(%22%22%22SELECT%20geo_id%2C%20geo_level%2C%20geo_name%2C%20labor_force%2C%20employed%2C%20unemployed%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20unemp_rate%2C%20participation_rate%2C%20ba_plus_share%2C%20median_hh_income%2C%20median_earnings%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20FROM%20acs_labor_force%20ORDER%20BY%20labor_force%22%22%22)%0A%20%20%20%20return%20(acs%2C)%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%205%20%C2%B7%20Who's%20in%20the%20labor%20force%20%20%C2%B7%20%20*residence-based%20(ACS%205-yr)%2C%20not%20workplace*%0A%0A%20%20%20%20Sections%201%E2%80%934%20counted%20**jobs%20located%20in%20the%20metro**%20(OEWS).%20From%20here%20we%20switch%20to%20**people%20who%0A%20%20%20%20live%20here**%20(ACS)%20%E2%80%94%20participation%2C%20unemployment%2C%20education%2C%20earnings%20%E2%80%94%20down%20to%20St.%20Petersburg%0A%20%20%20%20city.%20The%20two%20lenses%20answer%20different%20questions%3B%20they%20are%20shown%20side%20by%20side%2C%20never%20merged.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(acs%2C%20plt)%3A%0A%20%20%20%20_lbl%20%3D%20%5Bn.split(%22%2C%22)%5B0%5D.replace(%22%20city%22%2C%20%22%22).replace(%22%20Metro%22%2C%20%22%20metro%22)%20for%20n%20in%20acs.geo_name%5D%0A%20%20%20%20_x%20%3D%20range(len(acs))%0A%20%20%20%20_fig%2C%20_ax%20%3D%20plt.subplots(figsize%3D(8%2C%204.5))%0A%20%20%20%20_ax.bar(%5Bi%20-%200.2%20for%20i%20in%20_x%5D%2C%20acs.participation_rate%20*%20100%2C%20width%3D0.4%2C%20label%3D%22participation%20%25%22%2C%20color%3D%22%234C72B0%22)%0A%20%20%20%20_ax.bar(%5Bi%20%2B%200.2%20for%20i%20in%20_x%5D%2C%20acs.unemp_rate%20*%20100%2C%20width%3D0.4%2C%20label%3D%22unemployment%20%25%22%2C%20color%3D%22%23C44E52%22)%0A%20%20%20%20_ax.set_xticks(list(_x))%3B%20_ax.set_xticklabels(_lbl)%0A%20%20%20%20_ax.set_title(%22Labor-force%20participation%20%26%20unemployment%20%E2%80%94%20residence%20(ACS%202023)%22)%0A%20%20%20%20_ax.set_ylabel(%22percent%22)%3B%20_ax.legend()%3B%20_ax.grid(axis%3D%22y%22%2C%20alpha%3D0.3)%0A%20%20%20%20_fig%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%22%22%22%0A%20%20%20%20%23%23%206%20%C2%B7%20How%20educated%20is%20the%20resident%20workforce%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(acs%2C%20plt)%3A%0A%20%20%20%20_d%20%3D%20acs.sort_values(%22ba_plus_share%22)%0A%20%20%20%20_lbl%20%3D%20%5Bn.split(%22%2C%22)%5B0%5D.replace(%22%20city%22%2C%20%22%22).replace(%22%20Metro%22%2C%20%22%20metro%22)%20for%20n%20in%20_d.geo_name%5D%0A%20%20%20%20_fig%2C%20_ax%20%3D%20plt.subplots(figsize%3D(8%2C%203.8))%0A%20%20%20%20_ax.barh(_lbl%2C%20_d.ba_plus_share%20*%20100%2C%20color%3D%22%2355A868%22)%0A%20%20%20%20_ax.set_title(%22Bachelor's%20degree%20or%20higher%2C%20share%20of%20adults%2025%2B%20(ACS%202023)%22)%0A%20%20%20%20_ax.set_xlabel(%22percent%22)%3B%20_ax.grid(axis%3D%22x%22%2C%20alpha%3D0.3)%0A%20%20%20%20_fig.tight_layout()%0A%20%20%20%20_fig%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%207%20%C2%B7%20What%20residents%20earn%20%20%C2%B7%20%20*not%20comparable%20to%20OEWS%20wages*%0A%0A%20%20%20%20ACS%20median%20earnings%2Fhousehold%20income%20(what%20people%20who%20**live%20here**%20make)%20%E2%80%94%20distinct%20from%20the%0A%20%20%20%20OEWS%20wages%20in%20Section%202%20(what%20jobs%20**located%20here**%20pay).%20Different%20populations%2C%20different%0A%20%20%20%20statistics%3B%20do%20not%20read%20one%20against%20the%20other.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(acs%2C%20plt)%3A%0A%20%20%20%20_d%20%3D%20acs.sort_values(%22median_earnings%22)%0A%20%20%20%20_lbl%20%3D%20%5Bn.split(%22%2C%22)%5B0%5D.replace(%22%20city%22%2C%20%22%22).replace(%22%20Metro%22%2C%20%22%20metro%22)%20for%20n%20in%20_d.geo_name%5D%0A%20%20%20%20_y%20%3D%20range(len(_d))%0A%20%20%20%20_fig%2C%20_ax%20%3D%20plt.subplots(figsize%3D(8%2C%204))%0A%20%20%20%20_ax.barh(%5Bi%20%2B%200.2%20for%20i%20in%20_y%5D%2C%20_d.median_earnings%2C%20height%3D0.4%2C%20label%3D%22median%20earnings%22%2C%20color%3D%22%234C72B0%22)%0A%20%20%20%20_ax.barh(%5Bi%20-%200.2%20for%20i%20in%20_y%5D%2C%20_d.median_hh_income%2C%20height%3D0.4%2C%20label%3D%22median%20household%20income%22%2C%20color%3D%22%238172B3%22)%0A%20%20%20%20_ax.set_yticks(list(_y))%3B%20_ax.set_yticklabels(_lbl)%0A%20%20%20%20_ax.set_title(%22Resident%20earnings%20%26%20household%20income%20(ACS%202023)%22)%0A%20%20%20%20_ax.set_xlabel(%22dollars%22)%3B%20_ax.legend()%3B%20_ax.grid(axis%3D%22x%22%2C%20alpha%3D0.3)%0A%20%20%20%20_fig.tight_layout()%0A%20%20%20%20_fig%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%208%20%C2%B7%20Live%20here%20vs.%20work%20here%20%20%C2%B7%20%20*residence%20(ACS)%20vs%20workplace%20(OEWS)%2C%20metro*%0A%0A%20%20%20%20The%20same%205%20broad%20occupation%20categories%2C%20two%20lenses%20on%20the%20**same%20metro**%3A%20where%20residents%20work%0A%20%20%20%20(ACS%2C%20by%20residence)%20vs%20what%20jobs%20are%20located%20here%20(OEWS%2C%20by%20workplace).%20Gaps%20reflect%20commuting%0A%20%20%20%20across%20the%20metro%20boundary%20and%20the%20residence%2Fworkplace%20distinction%20%E2%80%94%20not%20an%20error.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(plt%2C%20q)%3A%0A%20%20%20%20%23%20OEWS%2022%20major%20groups%20-%3E%20the%205%20broad%20ACS%20categories%20(standard%20SOC%20crosswalk)%2C%20metro%20workplace.%0A%20%20%20%20_crosswalk%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%22Management%2C%20business%2C%20science%2C%20%26%20arts%22%3A%20%5B%2211-0000%22%2C%2213-0000%22%2C%2215-0000%22%2C%2217-0000%22%2C%2219-0000%22%2C%2221-0000%22%2C%2223-0000%22%2C%2225-0000%22%2C%2227-0000%22%2C%2229-0000%22%5D%2C%0A%20%20%20%20%20%20%20%20%22Service%22%3A%20%5B%2231-0000%22%2C%2233-0000%22%2C%2235-0000%22%2C%2237-0000%22%2C%2239-0000%22%5D%2C%0A%20%20%20%20%20%20%20%20%22Sales%20%26%20office%22%3A%20%5B%2241-0000%22%2C%2243-0000%22%5D%2C%0A%20%20%20%20%20%20%20%20%22Natural%20resources%2C%20construction%2C%20%26%20maintenance%22%3A%20%5B%2245-0000%22%2C%2247-0000%22%2C%2249-0000%22%5D%2C%0A%20%20%20%20%20%20%20%20%22Production%2C%20transportation%2C%20%26%20material%20moving%22%3A%20%5B%2251-0000%22%2C%2253-0000%22%5D%2C%0A%20%20%20%20%7D%0A%20%20%20%20_oews%20%3D%20q(%22%22%22SELECT%20soc_code%2C%20tot_emp%20FROM%20oews_occupation%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20WHERE%20area_fips%3D'0045300'%20AND%20soc_level%3D'major'%22%22%22)%0A%20%20%20%20_emp%20%3D%20dict(zip(_oews.soc_code%2C%20_oews.tot_emp))%0A%20%20%20%20_work%20%3D%20%7Bcat%3A%20sum(_emp.get(s%2C%200)%20for%20s%20in%20socs)%20for%20cat%2C%20socs%20in%20_crosswalk.items()%7D%0A%20%20%20%20_work_tot%20%3D%20sum(_work.values())%0A%20%20%20%20_acsocc%20%3D%20q(%22%22%22SELECT%20occ_group%2C%20employed%20FROM%20acs_occupation_residence%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20WHERE%20geo_id%3D'45300'%20AND%20occ_group%3C%3E'Total'%22%22%22)%0A%20%20%20%20_res%20%3D%20dict(zip(_acsocc.occ_group%2C%20_acsocc.employed))%0A%20%20%20%20_res_tot%20%3D%20sum(_res.values())%0A%20%20%20%20_cats%20%3D%20list(_crosswalk.keys())%0A%20%20%20%20_work_share%20%3D%20%5B100%20*%20_work%5Bc%5D%20%2F%20_work_tot%20for%20c%20in%20_cats%5D%0A%20%20%20%20_res_share%20%3D%20%5B100%20*%20_res.get(c%2C%200)%20%2F%20_res_tot%20for%20c%20in%20_cats%5D%0A%20%20%20%20_short%20%3D%20%5Bc.split(%22%2C%22)%5B0%5D.split(%22%20%26%22)%5B0%5D.split(%22%20occupations%22)%5B0%5D%5B%3A22%5D%20for%20c%20in%20_cats%5D%0A%20%20%20%20_y%20%3D%20range(len(_cats))%0A%20%20%20%20_fig%2C%20_ax%20%3D%20plt.subplots(figsize%3D(9%2C%205))%0A%20%20%20%20_ax.barh(%5Bi%20%2B%200.2%20for%20i%20in%20_y%5D%2C%20_work_share%2C%20height%3D0.4%2C%20label%3D%22workplace%20(OEWS)%22%2C%20color%3D%22%234C72B0%22)%0A%20%20%20%20_ax.barh(%5Bi%20-%200.2%20for%20i%20in%20_y%5D%2C%20_res_share%2C%20height%3D0.4%2C%20label%3D%22residence%20(ACS)%22%2C%20color%3D%22%23DD8452%22)%0A%20%20%20%20_ax.set_yticks(list(_y))%3B%20_ax.set_yticklabels(_short)%0A%20%20%20%20_ax.set_title(%22Occupation%20mix%2C%20Tampa%20metro%20%E2%80%94%20where%20jobs%20are%20(OEWS)%20vs%20where%20workers%20live%20(ACS)%22)%0A%20%20%20%20_ax.set_xlabel(%22share%20of%20employment%20(%25)%22)%3B%20_ax.legend()%3B%20_ax.grid(axis%3D%22x%22%2C%20alpha%3D0.3)%0A%20%20%20%20_fig.tight_layout()%0A%20%20%20%20_fig%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
dd6da2fb43ed8dbe16409803ca32b3f8