Gender Disparities in Labor Force Analysis (2024)
  • Home
  • Research Background
  • Analysis
    • Gender Disparities Overview
    • Data Cleaning & Preprocessing
    • Exploratory Data Analysis
    • Gender Dominance in Job Postings
    • Machine-Learning Models
    • NLP Analysis
    • Skill Gap Analysis
  • Career Strategy
  • About Us

On this page

  • Objective
  • Import Fred APIs
  • Gender Employment Overview
  • Women Share Across Sectors
    • Conclusion
  • Gender Dominace by Red vs. Blue States
    • Overview
    • Prepare the Dataset
    • Create an Alignment Map for Red vs. Blue State across US
    • Gender Share Across Red vs. Blue States
    • Conclusion

Gender Disparities Overview

  • Show All Code
  • Hide All Code

  • View Source

Cleaning, Exploration, and Patterns in the 2024 Job Market

Objective

In this section, we pull labor market data directly from the FRED API and organize it into two broad categories: STEM and non-STEM sectors. This structure allows us to compare gender representation across industries in a consistent, data-driven way. By separating technical fields from service-oriented ones, we can clearly highlight where women are underrepresented and where they hold a stronger labor market presence.

Import Fred APIs

We imported data from the FRED API using a predefined set of series IDs covering unemployment, participation, earnings, and industry-level employment. We then grouped these series into STEM and non-STEM sectors so we could analyze gender ratios and compare patterns across industries.

Code
import os
from dotenv import load_dotenv
from fredapi import Fred
import plotly.graph_objects as go
import plotly.io as pio
import pandas as pd
import plotly.express as px
import os

# os.makedirs("figures", exist_ok=True)

# Load API key from .env
load_dotenv()
fred = Fred(api_key=os.getenv("FRED_API_KEY"))

# List of series IDs and rename the variables (using data for women/men over 16)
series_map = {
    "unemp_total": "UNRATE", # Unemployment rate
    # Participation rate
    "part_women": "LNS11300002",
    "part_men": "LNS11300001",
    # Unemployment rate 
    "unemp_women": "LNS14000002",
    "unemp_men": "LNS14000001",
    # Median weekly earnings/full-time salaries
    "earn_women": "LEU0252882800A",
    "earn_men": "LEU0252881900A",
    # Total non-farm employees (seasonally adjusted, no data avalaible for men)
    "emp_nonfarm_total" : "PAYEMS",
    "emp_nonfarm_women" : "CES0000000010",
    "emp_nonfarm_women_ratio" : "CES0000000039", # women-to-all-employees ratio
    
    # STEM-leaning sectors (by industry): manufacturing; information (tech/media/communications); professional, scientific & technical services; mining & logging; utilities monthly, thousands of persons)
    # Manufacturing
    "emp_manu_women" : "CES3000000010", #SA
    #"emp_manu_men" : "CES3000000011",
    "emp_manu_women_ratio" : "CES3000000039", #SA, women-to-all-emp ratio
    # Information/Tech sector
    "emp_info_women" : "CES5000000010", #SA
    #"emp_info_men" : "CES5000000011",
    "emp_info_women_ratio" : "CES5000000039", #SA, women-to-all-emp ratio
    # Professional, scientific & technical services
    "emp_buser_women" : "CES6000000010", #SA
    #"emp_buser_men" : "CES6000000011",
    "emp_buser_women_ratio" : "CES6000000039", #SA, women-to-all-emp ratio
    # Construction
    "emp_construct_women" : "CES2000000010", # SA
    #"emp_construct_men" : "CES2000000011",
    "emp_construct_women_ratio" : "CES2000000039", #SA, women-to-all-emp ratio
    # Mining & Logging
    "emp_mining_women" : "CES1000000010", #SA
    #"emp_mining_men" : "CES1000000011",
    "emp_mining_women_ratio" : "CES1000000039", #SA, women-to-all-emp ratio
    # Utilities
    "emp_utl_women" : "CES4422000010", #SA
    #"emp_utl_men" : "CES4422000011",
    "emp_utl_women_ratio" : "CES4422000039", #SA, women-to-all-emp ratio
        
    # Non-STEM sectors: retail trade; leisure & hospitality; education & health services; financial activities; other services; government; trade, transportation & utilities (monthly, thousands of persons)
    # Retail Trade
    "emp_retail_women": "CES4200000010", #SA
    #"emp_retail_men": "CES4200000011",
    "emp_retail_women_ratio": "CES4200000039", #SA, women-to-all-emp ratio
    # Leisure & Hospitality
    "emp_leisure_women": "CES7000000010", #SA
    #"emp_leisure_men": "CES7000000011",
    "emp_leisure_women_ratio": "CES7000000039", #SA, women-to-all-emp ratio
    # Education & Health Services
    "emp_edhealth_women": "CES6500000010", #SA
    #"emp_edhealth_men": "CES6500000011",
    "emp_edhealth_women_ratio": "CES6500000039", #SA, women-to-all-emp ratio
    # Financial Activities
    "emp_finact_women": "CES5500000010",
    #"emp_finact_men": "CES5500000011",
    "emp_finact_women_ratio": "CES5500000039", #SA, women-to-all-emp ratio
    # Other Services (Excluding Gov)
    "emp_other_women": "CES8000000010",
    #"emp_other_men": "CES8000000011",
    "emp_other_women_ratio": "CES8000000039", #SA, women-to-all-emp ratio
    # Government
    "emp_gov_women": "CES9000000010",
    "emp_gov_women_ratio": "CES9000000039" #SA, women-to-all-emp ratio
}

# Download data
data = {label: fred.get_series(sid) for label, sid in series_map.items()}
#print(data["part_women"].head())

Gender Employment Overview

Chart 1: Unemployment Rate (Men vs Women)

Code
fig_unemp = go.Figure()
# Men unemployment rate
fig_unemp.add_trace(
    go.Scatter(
        x=data["unemp_men"].index,
        y=data["unemp_men"],
        mode="lines",
        name="Men"
    )
)
# Women unemployment rate
fig_unemp.add_trace(
    go.Scatter(
        x=data["unemp_women"].index,
        y=data["unemp_women"],
        mode="lines",
        name="Women"
    )
)
fig_unemp.update_layout(
    title="Unemployment Rate: Men vs Women",
    xaxis_title="Date",
    yaxis_title="Rate (%)",
    legend_title="Group",
    width=700,
    height=600,
    margin=dict(b=100),
    annotations=[
        dict(
            text="Source: U.S. Bureau of Labor Statistics via FRED",
            xref="paper", yref="paper",
            x=1, y=-0.15,
            showarrow=False,
            font=dict(size=10, color="gray"),
            xanchor="right"
        )
    ]
)
fig_unemp.show()

The line chart shows that men have consistently experienced slightly lower unemployment rates than women across most of modern U.S. economic history, with both groups following the same business-cycle peaks and troughs. The significant spike around 2020–2022 reflects the pandemic lockdown, though, surprisingly, women seem to recover more quickly, suggesting a faster re-entry into the labor market. Overall, despite short-term divergences, the long-run patterns show tightly linked movements between the two groups.

Chart 2: Labor Force Participation - Men vs Women (Monthly, SA)

Code
fig_part = go.Figure()
# Men participation line
fig_part.add_trace(
    go.Scatter(
        x=data["part_men"].index,
        y=data["part_men"],
        mode="lines",
        name="Men"
    )
)
# Women participation line
fig_part.add_trace(
    go.Scatter(
        x=data["part_women"].index,
        y=data["part_women"],
        mode="lines",
        name="Women"
    )
)
fig_part.update_layout(
    title="Labor Force Participation: Men vs Women (Monthly, SA)",
    xaxis_title="Year",
    yaxis_title="Percent (%)",
    legend_title="Group",
    width=700,
    height=600,
    margin=dict(b=100),
    annotations=[
        dict(
            text="Source: U.S. Bureau of Labor Statistics via FRED",
            xref="paper", yref="paper",
            x=1, y=-0.15,
            showarrow=False,
            font=dict(size=10, color="gray"),
            xanchor="right"
        )
    ]
)
fig_part.show()

From the 1950s through about 1990, the labor force was clearly male-dominated, with men’s participation consistently above 80% while women’s hovered near 33 - 45%, reflecting the era’s social norms in which men were expected to be the primary breadwinners. As societal attitudes shifted and educational and professional opportunities expanded, women’s participation rose steadily - climbing from roughly 32% in 1950 to nearly 60% by 2000. Today, the gap has narrowed significantly, indicating a more balanced workforce compared to historical patterns.

Chart 3: Gender Wage Gap Over Time (Median Weekly Earnings)

Code
fig_wage = go.Figure()
# Men earnings line
fig_wage.add_trace(
    go.Scatter(
        x=data["earn_men"].index,
        y=data["earn_men"],
        mode="lines",
        name="Men"
    )
)
# Women earnings line
fig_wage.add_trace(
    go.Scatter(
        x=data["earn_women"].index,
        y=data["earn_women"],
        mode="lines",
        name="Women"
    )
)
fig_wage.update_layout(
    title="Median Weekly Earnings: Men vs Women",
    xaxis_title="Year",
    yaxis_title="USD",
    legend_title="Group",
    width=700,
    height=600,
    margin=dict(b=100),
    annotations=[
        dict(
            text="Source: U.S. Bureau of Labor Statistics via FRED",
            xref="paper", yref="paper",
            x=1, y=-0.15,
            showarrow=False,
            font=dict(size=10, color="gray"),
            xanchor="right"
        )
    ]
)
fig_wage.show()

The chart highlights the long-run narrowing of the gender earnings gap: around 1950s - 1980s, men earned around $380–$400 per week while women earned closer to $240–$260, meaning men made roughly double at the time. Since then, women’s median weekly earnings have risen steadily, from about $250 in 1980 to over $330 today, showing positive progress in workforce representation and pay equity. However, despite this catch-up, men continue to earn more on average, indicating that the earnings gap, while smaller, remains noticeable.


Women Share Across Sectors

Chart 1: STEM SECTORS – Women Ratio Bar Chart

Code
# Get the latest information available from Fred
def get_latest(series):
    s = series.dropna()
    return s.index[-1], s.iloc[-1]  # (date, value)

stem_ratio_vars = {
    "Manufacturing": data["emp_manu_women_ratio"],
    "Information (Tech)": data["emp_info_women_ratio"],
    "Prof/Scientific/Tech": data["emp_buser_women_ratio"],
    "Construction": data["emp_construct_women_ratio"],
    "Mining & Logging": data["emp_mining_women_ratio"],
    "Utilities": data["emp_utl_women_ratio"]
}

# Latest values + dates for each sector then sort the sectors
stem_latest_data = {sector: get_latest(series) for sector, series in stem_ratio_vars.items()}
stem_sorted = pd.Series({k: v[1] for k, v in stem_latest_data.items()}).sort_values(ascending=False)
# Get most recent date across all STEM series
stem_latest_date = max(v[0] for v in stem_latest_data.values()).strftime("%Y-%m")

fig_stem = go.Figure()
fig_stem.add_trace(
    go.Bar(
        x=stem_sorted.index,
        y=stem_sorted.values,
        text=[f"{v:.1f}%" for v in stem_sorted.values],
        textposition="outside"
    )
)
fig_stem.update_layout(
    title=f"Share of Women in STEM Sectors ({stem_latest_date})",
    yaxis_title="% of Total Employment",
    xaxis_title="STEM Sector",
    xaxis_tickangle=30,
    width=700,
    height=500,
    margin=dict(t=100),
    annotations=[
        dict(
            text="Source: U.S. Bureau of Labor Statistics (BLS) via FRED",
            xref="paper", yref="paper",
            x=0, y=1.15,
            showarrow=False,
            font=dict(size=10, color="gray"),
            xanchor="left"
        )
    ]
)
fig_stem.show()

The STEM bar chart highlights that women remain underrepresented in most technical fields, with their highest shares in Professional/Scientific/Tech (45%) and Information/Tech (40%). Participation drops sharply in more traditional industrial sectors like Manufacturing (29%), Utilities (26%), and especially Construction and Mining, where women make up only about 14%. This pattern suggests that while women have made meaningful intakes into knowledge-based and tech-oriented STEM roles, the more physically intensive or legacy STEM industries still lag far behind.

Chart 2: NON-STEM SECTORS – Women Ratio Bar Chart

Code
nonstem_ratio_vars = {
    "Leisure & Hospitality": data["emp_leisure_women_ratio"],
    "Education & Health": data["emp_edhealth_women_ratio"],
    "Financial Activities": data["emp_finact_women_ratio"],
    "Other Services": data["emp_other_women_ratio"],
    "Government": data["emp_gov_women_ratio"],
    "Retail Trade": data["emp_retail_women_ratio"]
}

# Latest value for each sector then sort the sectors
nonstem_latest_data = {sector: get_latest(series) for sector, series in nonstem_ratio_vars.items()}
nonstem_sorted = pd.Series({k: v[1] for k, v in nonstem_latest_data.items()}).sort_values(ascending=False)
# Get the most recent update date
nonstem_latest_date = max(v[0] for v in nonstem_latest_data.values()).strftime("%Y-%m")
fig_nonstem = go.Figure()
fig_nonstem.add_trace(
    go.Bar(
        x=nonstem_sorted.index,
        y=nonstem_sorted.values,
        text=[f"{v:.1f}%" for v in nonstem_sorted.values],
        textposition="outside",
        marker_color="indianred"
    )
)
fig_nonstem.update_layout(
    title=f"Share of Women in Non-STEM Sectors ({nonstem_latest_date})",
    yaxis_title="% of Total Employment",
    xaxis_title="Non-STEM Sector",
    xaxis_tickangle=30,
    width=700,
    height=500,
    margin=dict(t=100),
    annotations=[
        dict(
            text="Source: U.S. Bureau of Labor Statistics (BLS) via FRED",
            xref="paper", yref="paper",
            x=0, y=1.15,
            showarrow=False,
            font=dict(size=10, color="gray"),
            xanchor="left"
        )
    ]
)
fig_nonstem.show()

In contrast, the non-STEM chart shows a very different landscape: women hold the majority of jobs across all major non-STEM sectors. They dominate Education & Health at over 76%, and maintain strong majorities in Government (59%), Financial Activities (55%), and other service-oriented industries. Even in Retail Trade, the most balanced sector, women still represent nearly half of the workforce.

Conclusion

Together, the two charts highlight a clear divide: women are well-represented and often leading in service-based, caregiving, and administrative sectors, but continue to face barriers to entry and advancement in many STEM and industrial occupations.


Gender Dominace by Red vs. Blue States

Overview

This section compares gender representation in the workforce between red and blue states to see whether political alignment corresponds with different gender patterns. In U.S. politics, “red states” represent Republican, while “blue states” lean Democratic - two ideologies that often diverge on social policies, labor protections, childcare support, and broader economic priorities. These differences can indirectly shape workforce participation by influencing factors such as family leave access, childcare affordability, or employment conditions.

By examining population shares from 2021 to 2024, the charts highlight how gender patterns evolve over time and reveal where notable differences appear between red and blue states.

Prepare the Dataset

Code
# Load the dataset for state population by gender (2021-2024) 
df_state = pd.read_csv("data/acs_computer_math_gender_by_state_5yrs.csv")

# Compute gender shares between states 
df_state["female_pct"] = (df_state["cm_female"] / df_state["cm_total"] * 100).round(2) 
df_state["male_pct"] = (df_state["cm_male"] / df_state["cm_total"] * 100).round(2) 

df_state.head()
state_name cm_total cm_male cm_female state_fips year female_pct male_pct
0 Alabama 71337 53744 17593 1 2024 24.66 75.34
1 Alaska 7612 5404 2208 2 2024 29.01 70.99
2 Arizona 131692 99549 32143 4 2024 24.41 75.59
3 Arkansas 38412 25353 13059 5 2024 34.00 66.00
4 California 891291 642532 248759 6 2024 27.91 72.09

Create an Alignment Map for Red vs. Blue State across US

Code
state_align_map = { 
    # Blue states 
    "California": "Blue", "Colorado": "Blue", "Connecticut": "Blue", "Delaware": "Blue", "District of Columbia": "Blue", "Hawaii": "Blue", "Illinois": "Blue", "Maine": "Blue", "Maryland": "Blue", "Massachusetts": "Blue", "Minnesota": "Blue", "Nevada": "Blue", "New Hampshire": "Blue", "New Jersey": "Blue", "New Mexico": "Blue", "New York": "Blue", "Oregon": "Blue", "Rhode Island": "Blue", "Vermont": "Blue", "Virginia": "Blue", "Washington": "Blue", "Georgia": "Blue", "Arizona": "Blue", "Pennsylvania": "Blue", "Michigan": "Blue", "Wisconsin": "Blue", 

    # Red states (Republican-leaning in 2020)
    "Alabama": "Red", "Alaska": "Red", "Arkansas": "Red", "Florida": "Red", "Idaho": "Red", "Indiana": "Red", "Iowa": "Red", "Kansas": "Red", "Kentucky": "Red", "Louisiana": "Red", "Mississippi": "Red", "Missouri": "Red", "Montana": "Red", "Nebraska": "Red", "North Carolina": "Red", "North Dakota": "Red", "Ohio": "Red", "Oklahoma": "Red", "South Carolina": "Red", "South Dakota": "Red", "Tennessee": "Red", "Texas": "Red", "Utah": "Red", "West Virginia": "Red", "Wyoming": "Red", 

    # Territories 
    "Puerto Rico": "Territory" } 

df_state["alignment"] = df_state["state_name"].map(state_align_map) 

df_state.head() 

# Drop Puerto Rico and any non-aligned rows
df_state = df_state[df_state["alignment"].isin(["Red","Blue"])].copy() 

# Aggregate by alignment + year 
state_agg = (df_state.groupby(["year","alignment"])[["female_pct","male_pct"]].mean().reset_index().round(2))

display(state_agg) 
year alignment female_pct male_pct
0 2021 Blue 27.03 72.97
1 2021 Red 25.92 74.08
2 2022 Blue 26.93 73.07
3 2022 Red 26.16 73.84
4 2023 Blue 26.30 73.70
5 2023 Red 25.72 74.28
6 2024 Blue 26.71 73.29
7 2024 Red 27.16 72.84

Gender Share Across Red vs. Blue States

Chart 1: Women Share in Blue vs Red States (2021–2024)

Code
color_map = {
    "Blue": "rgba(0, 102, 204, 0.8)",
    "Red": "rgba(204, 0, 0, 0.8)"
}

fig_female = px.bar(
    state_agg,
    x="year",
    y="female_pct",
    color="alignment",
    barmode="group",
    text="female_pct",
    labels={"female_pct": "Women Share (%)"},
    title="Women Share in Blue vs Red States (2021–2024)",
    color_discrete_map=color_map
)

fig_female.update_traces(texttemplate="%{text:.2f}", textposition="outside")

fig_female.update_layout(
    xaxis_title="Year",
    yaxis_title="Women Share (%)",
    legend_title="State Alignment",
    width=800,
    height=500
)
fig_female.show()

The chart shows that the women’s share of the total population is consistently higher in blue states across 2021–2023, with a narrow but stable margin. In 2024, however, the pattern briefly reverses, with red states showing a slightly higher women’s share. Overall, the gap is small, but the data suggests blue states generally maintain a modestly larger female population share over most of the period.

Chart 2: Women vs. Men Share in Red States (2021-2024)

Code
stacked_data = state_agg.melt(
    id_vars=["year","alignment"],
    value_vars=["female_pct","male_pct"],
    var_name="gender",
    value_name="percentage"
)

colors_red = {
    "male_pct": "rgba(238, 195, 195, 0.8)",
    "female_pct": "rgba(204, 0, 0, 0.8)"
}

# Red States Stacked Bar Chart
df_red = stacked_data[stacked_data["alignment"] == "Red"]

fig_red = px.bar(
    df_red,
    x="year",
    y="percentage",
    color="gender",
    barmode="stack",
    text="percentage",
    labels={"percentage": "Share (%)"},
    title="Women vs. Men in Red States (2021–2024)",
    color_discrete_map=colors_red
)

fig_red.update_traces(texttemplate="%{text:.2f}", textposition="inside")
fig_red.update_layout(
    xaxis_title="Year",
    yaxis_title="Share (%)",
    legend_title="Gender",
    width=700,
    height=500
)
fig_red.show()

In red states, the gender balance stays remarkably steady, with women consistently making up about one-quarter of the population. The small bump in 2024 suggests a slight shift, but not significant change the overall picture. Men continue to represent the clear majority, holding roughly three-quarters of the population each year.

Chart 3: Women vs. Men Share in Blue States (2021-2024)

Code
# Blue States Stacked Bar Chart
df_blue = stacked_data[stacked_data["alignment"] == "Blue"]

colors_blue = {
    "male_pct": "rgba(185, 212, 240, 0.8)",
    "female_pct": "rgba(0, 102, 204, 0.8)"
}

fig_blue = px.bar(
    df_blue,
    x="year",
    y="percentage",
    color="gender",
    barmode="stack",
    text="percentage",
    labels={"percentage": "Share (%)"},
    title="Women vs. Men in Blue States (2021–2024)",
    color_discrete_map=colors_blue
)

fig_blue.update_traces(texttemplate="%{text:.2f}", textposition="inside")
fig_blue.update_layout(
    xaxis_title="Year",
    yaxis_title="Share (%)",
    legend_title="Gender",
    width=700,
    height=500
)
fig_blue.show()

Blue states show a similarly stable pattern, with women holding a slightly larger share than in red states, usually around 26 to 27%. Although there’s a minor dip in 2022 and 2023, the female share rebounds in 2024, keeping the overall trend fairly consistent. Compared to red states, blue states continue to lean just a bit more female across the full period.

Chart 4: US Women Share by State (2024)

Code
state_to_abbrev = {
    "Alabama":"AL","Alaska":"AK","Arizona":"AZ","Arkansas":"AR","California":"CA","Colorado":"CO",
    "Connecticut":"CT","Delaware":"DE","District of Columbia":"DC","Florida":"FL","Georgia":"GA",
    "Hawaii":"HI","Idaho":"ID","Illinois":"IL","Indiana":"IN","Iowa":"IA","Kansas":"KS","Kentucky":"KY",
    "Louisiana":"LA","Maine":"ME","Maryland":"MD","Massachusetts":"MA","Michigan":"MI","Minnesota":"MN",
    "Mississippi":"MS","Missouri":"MO","Montana":"MT","Nebraska":"NE","Nevada":"NV","New Hampshire":"NH",
    "New Jersey":"NJ","New Mexico":"NM","New York":"NY","North Carolina":"NC","North Dakota":"ND",
    "Ohio":"OH","Oklahoma":"OK","Oregon":"OR","Pennsylvania":"PA","Rhode Island":"RI","South Carolina":"SC",
    "South Dakota":"SD","Tennessee":"TN","Texas":"TX","Utah":"UT","Vermont":"VT","Virginia":"VA",
    "Washington":"WA","West Virginia":"WV","Wisconsin":"WI","Wyoming":"WY"
}

# Approximate state centroids (lat/lon)
state_centroids = {
    "AL":(32.806671, -86.791130),"AK":(61.370716, -152.404419),"AZ":(33.729759, -111.431221),
    "AR":(34.969704, -92.373123),"CA":(36.116203, -119.681564),"CO":(39.059811, -105.311104),
    "CT":(41.597782, -72.755371),"DE":(39.318523, -75.507141),"DC":(38.897438, -77.026817),
    "FL":(27.766279, -81.686783),"GA":(33.040619, -83.643074),"HI":(21.094318, -157.498337),
    "ID":(44.240459, -114.478828),"IL":(40.349457, -88.986137),"IN":(39.849426, -86.258278),
    "IA":(42.011539, -93.210526),"KS":(38.526600, -96.726486),"KY":(37.668140, -84.670067),
    "LA":(31.169546, -91.867805),"ME":(44.693947, -69.381927),"MD":(39.063946, -76.802101),
    "MA":(42.230171, -71.530106),"MI":(43.326618, -84.536095),"MN":(45.694454, -93.900192),
    "MS":(32.741646, -89.678696),"MO":(38.456085, -92.288368),"MT":(46.921925, -110.454353),
    "NE":(41.125370, -98.268082),"NV":(38.313515, -117.055374),"NH":(43.452492, -71.563896),
    "NJ":(40.298904, -74.521011),"NM":(34.840515, -106.248482),"NY":(42.165726, -74.948051),
    "NC":(35.630066, -79.806419),"ND":(47.528912, -99.784012),"OH":(40.388783, -82.764915),
    "OK":(35.565342, -96.928917),"OR":(44.572021, -122.070938),"PA":(40.590752, -77.209755),
    "RI":(41.680893, -71.511780),"SC":(33.856892, -80.945007),"SD":(44.299782, -99.438828),
    "TN":(35.747845, -86.692345),"TX":(31.054487, -97.563461),"UT":(40.150032, -111.862434),
    "VT":(44.045876, -72.710686),"VA":(37.769337, -78.169968),"WA":(47.400902, -121.490494),
    "WV":(38.491226, -80.954456),"WI":(44.268543, -89.616508),"WY":(42.755966, -107.302490)
}

# Choose the year to show
year_choice = 2024

df_year = df_state[df_state["year"] == year_choice].copy()
df_year["state_code"] = df_year["state_name"].map(state_to_abbrev)
df_year = df_year[df_year["state_code"].notna()].copy()

df_year["align_val"] = df_year["alignment"].map({"Red": 0, "Blue": 1})
df_year["lat"] = df_year["state_code"].map(lambda x: state_centroids[x][0])
df_year["lon"] = df_year["state_code"].map(lambda x: state_centroids[x][1])

color_map = {
    "Blue": "rgba(0, 102, 204, 0.8)",
    "Red": "rgba(204, 0, 0, 0.8)"
}

fig = go.Figure()

# Base layer
fig.add_trace(go.Choropleth(
    locations=df_year["state_code"],
    z=df_year["align_val"],
    locationmode="USA-states",
    colorscale=[[0, color_map["Red"]], [1, color_map["Blue"]]],
    showscale=False,
    marker_line_color="white",
    marker_line_width=0.5
))

# Bubble overlay: only state name visible, female_pct in hover
fig.add_trace(go.Scattergeo(
    lon=df_year["lon"],
    lat=df_year["lat"],
    text=df_year["state_code"],
    hovertext=df_year.apply(lambda r: f"{r['state_name']}<br>Female: {r['female_pct']:.1f}%", axis=1),
    marker=dict(
        size=df_year["female_pct"] * 1.5,
        color="white",
        opacity=0.85,
        line=dict(width=0.5, color="black")
    ),
    mode="markers+text",
    textposition="middle center",
    hoverinfo="text",
    name="Female Share"
))

fig.update_layout(
    title=f"US Women Share by State ({year_choice})",
    title_x=0.5,
    margin=dict(t=80),
    geo=dict(
        scope="usa",
        projection=go.layout.geo.Projection(type="albers usa"),
        showland=True,
        landcolor="rgb(240,240,240)"
    ),
    width=800,
    height=600,
    legend_title_text="Women Share"
)

fig.show()

The 2024 map shows that several red states have some of the largest bubbles, indicating higher female employment shares, particularly Mississippi (36%), Arkansas (34%), Louisiana (32.1%), and Wyoming (31.7%). The highest-share blue area is the District of Columbia at 35.6%. Together, these values line up with the earlier observation that in 2024, the women’s share happens to be slightly higher in red states than in blue states.

Conclusion

Across the four-year period, blue states consistently show a slightly higher women’s share overall, but 2024 stands out with red states surpassing blue states by a narrow margin. The state-level map reinforces this shift, with several red states displaying notably high female employment shares. Taken together, these results suggest that while political alignment reflects broad trends, gender dynamics can still vary meaningfully at the state level.

© 2025 · AD 688 Web Analytics · Boston University

Team 5

Source Code
---
title: "Gender Disparities Overview"
subtitle: "Cleaning, Exploration, and Patterns in the 2024 Job Market"
bibliography: references.bib
csl: csl/econometrica.csl
format:
  html:
    code-fold: true
    code-tools: true
---

<div class="card reveal">

## Objective

In this section, we pull labor market data directly from the FRED API and organize it into two broad categories: STEM and non-STEM sectors. This structure allows us to compare gender representation across industries in a consistent, data-driven way. By separating technical fields from service-oriented ones, we can clearly highlight where women are underrepresented and where they hold a stronger labor market presence.

</div>

<div class="card reveal">

## Import Fred APIs

We imported data from the FRED API using a predefined set of series IDs covering unemployment, participation, earnings, and industry-level employment. We then grouped these series into STEM and non-STEM sectors so we could analyze gender ratios and compare patterns across industries.

```{python}
import os
from dotenv import load_dotenv
from fredapi import Fred
import plotly.graph_objects as go
import plotly.io as pio
import pandas as pd
import plotly.express as px
import os

# os.makedirs("figures", exist_ok=True)

# Load API key from .env
load_dotenv()
fred = Fred(api_key=os.getenv("FRED_API_KEY"))

# List of series IDs and rename the variables (using data for women/men over 16)
series_map = {
    "unemp_total": "UNRATE", # Unemployment rate
    # Participation rate
    "part_women": "LNS11300002",
    "part_men": "LNS11300001",
    # Unemployment rate 
    "unemp_women": "LNS14000002",
    "unemp_men": "LNS14000001",
    # Median weekly earnings/full-time salaries
    "earn_women": "LEU0252882800A",
    "earn_men": "LEU0252881900A",
    # Total non-farm employees (seasonally adjusted, no data avalaible for men)
    "emp_nonfarm_total" : "PAYEMS",
    "emp_nonfarm_women" : "CES0000000010",
    "emp_nonfarm_women_ratio" : "CES0000000039", # women-to-all-employees ratio
    
    # STEM-leaning sectors (by industry): manufacturing; information (tech/media/communications); professional, scientific & technical services; mining & logging; utilities monthly, thousands of persons)
    # Manufacturing
    "emp_manu_women" : "CES3000000010", #SA
    #"emp_manu_men" : "CES3000000011",
    "emp_manu_women_ratio" : "CES3000000039", #SA, women-to-all-emp ratio
    # Information/Tech sector
    "emp_info_women" : "CES5000000010", #SA
    #"emp_info_men" : "CES5000000011",
    "emp_info_women_ratio" : "CES5000000039", #SA, women-to-all-emp ratio
    # Professional, scientific & technical services
    "emp_buser_women" : "CES6000000010", #SA
    #"emp_buser_men" : "CES6000000011",
    "emp_buser_women_ratio" : "CES6000000039", #SA, women-to-all-emp ratio
    # Construction
    "emp_construct_women" : "CES2000000010", # SA
    #"emp_construct_men" : "CES2000000011",
    "emp_construct_women_ratio" : "CES2000000039", #SA, women-to-all-emp ratio
    # Mining & Logging
    "emp_mining_women" : "CES1000000010", #SA
    #"emp_mining_men" : "CES1000000011",
    "emp_mining_women_ratio" : "CES1000000039", #SA, women-to-all-emp ratio
    # Utilities
    "emp_utl_women" : "CES4422000010", #SA
    #"emp_utl_men" : "CES4422000011",
    "emp_utl_women_ratio" : "CES4422000039", #SA, women-to-all-emp ratio
        
    # Non-STEM sectors: retail trade; leisure & hospitality; education & health services; financial activities; other services; government; trade, transportation & utilities (monthly, thousands of persons)
    # Retail Trade
    "emp_retail_women": "CES4200000010", #SA
    #"emp_retail_men": "CES4200000011",
    "emp_retail_women_ratio": "CES4200000039", #SA, women-to-all-emp ratio
    # Leisure & Hospitality
    "emp_leisure_women": "CES7000000010", #SA
    #"emp_leisure_men": "CES7000000011",
    "emp_leisure_women_ratio": "CES7000000039", #SA, women-to-all-emp ratio
    # Education & Health Services
    "emp_edhealth_women": "CES6500000010", #SA
    #"emp_edhealth_men": "CES6500000011",
    "emp_edhealth_women_ratio": "CES6500000039", #SA, women-to-all-emp ratio
    # Financial Activities
    "emp_finact_women": "CES5500000010",
    #"emp_finact_men": "CES5500000011",
    "emp_finact_women_ratio": "CES5500000039", #SA, women-to-all-emp ratio
    # Other Services (Excluding Gov)
    "emp_other_women": "CES8000000010",
    #"emp_other_men": "CES8000000011",
    "emp_other_women_ratio": "CES8000000039", #SA, women-to-all-emp ratio
    # Government
    "emp_gov_women": "CES9000000010",
    "emp_gov_women_ratio": "CES9000000039" #SA, women-to-all-emp ratio
}

# Download data
data = {label: fred.get_series(sid) for label, sid in series_map.items()}
#print(data["part_women"].head())
```

</div>

---

<div class="card reveal">

## Gender Employment Overview

**Chart 1: Unemployment Rate (Men vs Women)**

```{python}
fig_unemp = go.Figure()
# Men unemployment rate
fig_unemp.add_trace(
    go.Scatter(
        x=data["unemp_men"].index,
        y=data["unemp_men"],
        mode="lines",
        name="Men"
    )
)
# Women unemployment rate
fig_unemp.add_trace(
    go.Scatter(
        x=data["unemp_women"].index,
        y=data["unemp_women"],
        mode="lines",
        name="Women"
    )
)
fig_unemp.update_layout(
    title="Unemployment Rate: Men vs Women",
    xaxis_title="Date",
    yaxis_title="Rate (%)",
    legend_title="Group",
    width=700,
    height=600,
    margin=dict(b=100),
    annotations=[
        dict(
            text="Source: U.S. Bureau of Labor Statistics via FRED",
            xref="paper", yref="paper",
            x=1, y=-0.15,
            showarrow=False,
            font=dict(size=10, color="gray"),
            xanchor="right"
        )
    ]
)
fig_unemp.show()
```

The line chart shows that men have consistently experienced slightly lower unemployment rates than women across most of modern U.S. economic history, with both groups following the same business-cycle peaks and troughs. The significant spike around 2020–2022 reflects the pandemic lockdown, though, surprisingly, women seem to recover more quickly, suggesting a faster re-entry into the labor market. Overall, despite short-term divergences, the long-run patterns show tightly linked movements between the two groups.

**Chart 2: Labor Force Participation - Men vs Women (Monthly, SA)**

```{python}
fig_part = go.Figure()
# Men participation line
fig_part.add_trace(
    go.Scatter(
        x=data["part_men"].index,
        y=data["part_men"],
        mode="lines",
        name="Men"
    )
)
# Women participation line
fig_part.add_trace(
    go.Scatter(
        x=data["part_women"].index,
        y=data["part_women"],
        mode="lines",
        name="Women"
    )
)
fig_part.update_layout(
    title="Labor Force Participation: Men vs Women (Monthly, SA)",
    xaxis_title="Year",
    yaxis_title="Percent (%)",
    legend_title="Group",
    width=700,
    height=600,
    margin=dict(b=100),
    annotations=[
        dict(
            text="Source: U.S. Bureau of Labor Statistics via FRED",
            xref="paper", yref="paper",
            x=1, y=-0.15,
            showarrow=False,
            font=dict(size=10, color="gray"),
            xanchor="right"
        )
    ]
)
fig_part.show()
```

From the 1950s through about 1990, the labor force was clearly male-dominated, with men’s participation consistently above 80% while women’s hovered near 33 - 45%, reflecting the era’s social norms in which men were expected to be the primary breadwinners. As societal attitudes shifted and educational and professional opportunities expanded, women’s participation rose steadily - climbing from roughly 32% in 1950 to nearly 60% by 2000. Today, the gap has narrowed significantly, indicating a more balanced workforce compared to historical patterns.

**Chart 3: Gender Wage Gap Over Time (Median Weekly Earnings)**

```{python}
fig_wage = go.Figure()
# Men earnings line
fig_wage.add_trace(
    go.Scatter(
        x=data["earn_men"].index,
        y=data["earn_men"],
        mode="lines",
        name="Men"
    )
)
# Women earnings line
fig_wage.add_trace(
    go.Scatter(
        x=data["earn_women"].index,
        y=data["earn_women"],
        mode="lines",
        name="Women"
    )
)
fig_wage.update_layout(
    title="Median Weekly Earnings: Men vs Women",
    xaxis_title="Year",
    yaxis_title="USD",
    legend_title="Group",
    width=700,
    height=600,
    margin=dict(b=100),
    annotations=[
        dict(
            text="Source: U.S. Bureau of Labor Statistics via FRED",
            xref="paper", yref="paper",
            x=1, y=-0.15,
            showarrow=False,
            font=dict(size=10, color="gray"),
            xanchor="right"
        )
    ]
)
fig_wage.show()
```

The chart highlights the long-run narrowing of the gender earnings gap: around 1950s - 1980s, men earned around $380–$400 per week while women earned closer to $240–$260, meaning men made roughly double at the time. Since then, women’s median weekly earnings have risen steadily, from about $250 in 1980 to over $330 today, showing positive progress in workforce representation and pay equity. However, despite this catch-up, men continue to earn more on average, indicating that the earnings gap, while smaller, remains noticeable.

</div>

---

<div class="card reveal">

## Women Share Across Sectors

**Chart 1: STEM SECTORS – Women Ratio Bar Chart**

```{python}
# Get the latest information available from Fred
def get_latest(series):
    s = series.dropna()
    return s.index[-1], s.iloc[-1]  # (date, value)

stem_ratio_vars = {
    "Manufacturing": data["emp_manu_women_ratio"],
    "Information (Tech)": data["emp_info_women_ratio"],
    "Prof/Scientific/Tech": data["emp_buser_women_ratio"],
    "Construction": data["emp_construct_women_ratio"],
    "Mining & Logging": data["emp_mining_women_ratio"],
    "Utilities": data["emp_utl_women_ratio"]
}

# Latest values + dates for each sector then sort the sectors
stem_latest_data = {sector: get_latest(series) for sector, series in stem_ratio_vars.items()}
stem_sorted = pd.Series({k: v[1] for k, v in stem_latest_data.items()}).sort_values(ascending=False)
# Get most recent date across all STEM series
stem_latest_date = max(v[0] for v in stem_latest_data.values()).strftime("%Y-%m")

fig_stem = go.Figure()
fig_stem.add_trace(
    go.Bar(
        x=stem_sorted.index,
        y=stem_sorted.values,
        text=[f"{v:.1f}%" for v in stem_sorted.values],
        textposition="outside"
    )
)
fig_stem.update_layout(
    title=f"Share of Women in STEM Sectors ({stem_latest_date})",
    yaxis_title="% of Total Employment",
    xaxis_title="STEM Sector",
    xaxis_tickangle=30,
    width=700,
    height=500,
    margin=dict(t=100),
    annotations=[
        dict(
            text="Source: U.S. Bureau of Labor Statistics (BLS) via FRED",
            xref="paper", yref="paper",
            x=0, y=1.15,
            showarrow=False,
            font=dict(size=10, color="gray"),
            xanchor="left"
        )
    ]
)
fig_stem.show()
```

The STEM bar chart highlights that women remain underrepresented in most technical fields, with their highest shares in Professional/Scientific/Tech (45%) and Information/Tech (40%). Participation drops sharply in more traditional industrial sectors like Manufacturing (29%), Utilities (26%), and especially Construction and Mining, where women make up only about 14%. This pattern suggests that while women have made meaningful intakes into knowledge-based and tech-oriented STEM roles, the more physically intensive or legacy STEM industries still lag far behind.

**Chart 2: NON-STEM SECTORS – Women Ratio Bar Chart**

```{python}
nonstem_ratio_vars = {
    "Leisure & Hospitality": data["emp_leisure_women_ratio"],
    "Education & Health": data["emp_edhealth_women_ratio"],
    "Financial Activities": data["emp_finact_women_ratio"],
    "Other Services": data["emp_other_women_ratio"],
    "Government": data["emp_gov_women_ratio"],
    "Retail Trade": data["emp_retail_women_ratio"]
}

# Latest value for each sector then sort the sectors
nonstem_latest_data = {sector: get_latest(series) for sector, series in nonstem_ratio_vars.items()}
nonstem_sorted = pd.Series({k: v[1] for k, v in nonstem_latest_data.items()}).sort_values(ascending=False)
# Get the most recent update date
nonstem_latest_date = max(v[0] for v in nonstem_latest_data.values()).strftime("%Y-%m")
fig_nonstem = go.Figure()
fig_nonstem.add_trace(
    go.Bar(
        x=nonstem_sorted.index,
        y=nonstem_sorted.values,
        text=[f"{v:.1f}%" for v in nonstem_sorted.values],
        textposition="outside",
        marker_color="indianred"
    )
)
fig_nonstem.update_layout(
    title=f"Share of Women in Non-STEM Sectors ({nonstem_latest_date})",
    yaxis_title="% of Total Employment",
    xaxis_title="Non-STEM Sector",
    xaxis_tickangle=30,
    width=700,
    height=500,
    margin=dict(t=100),
    annotations=[
        dict(
            text="Source: U.S. Bureau of Labor Statistics (BLS) via FRED",
            xref="paper", yref="paper",
            x=0, y=1.15,
            showarrow=False,
            font=dict(size=10, color="gray"),
            xanchor="left"
        )
    ]
)
fig_nonstem.show()
```

In contrast, the non-STEM chart shows a very different landscape: women hold the majority of jobs across all major non-STEM sectors. They dominate Education & Health at over 76%, and maintain strong majorities in Government (59%), Financial Activities (55%), and other service-oriented industries. Even in Retail Trade, the most balanced sector, women still represent nearly half of the workforce. 

### Conclusion

Together, the two charts highlight a clear divide: women are well-represented and often leading in service-based, caregiving, and administrative sectors, but continue to face barriers to entry and advancement in many STEM and industrial occupations.

</div>

---

<div class="card reveal">

## Gender Dominace by Red vs. Blue States

### Overview

This section compares gender representation in the workforce between red and blue states to see whether political alignment corresponds with different gender patterns. In U.S. politics, “red states” represent Republican, while “blue states” lean Democratic - two ideologies that often diverge on social policies, labor protections, childcare support, and broader economic priorities. These differences can indirectly shape workforce participation by influencing factors such as family leave access, childcare affordability, or employment conditions. 

By examining population shares from 2021 to 2024, the charts highlight how gender patterns evolve over time and reveal where notable differences appear between red and blue states.

### Prepare the Dataset
```{python}
# Load the dataset for state population by gender (2021-2024) 
df_state = pd.read_csv("data/acs_computer_math_gender_by_state_5yrs.csv")

# Compute gender shares between states 
df_state["female_pct"] = (df_state["cm_female"] / df_state["cm_total"] * 100).round(2) 
df_state["male_pct"] = (df_state["cm_male"] / df_state["cm_total"] * 100).round(2) 

df_state.head()
```

### Create an Alignment Map for Red vs. Blue State across US
```{python}
state_align_map = { 
    # Blue states 
    "California": "Blue", "Colorado": "Blue", "Connecticut": "Blue", "Delaware": "Blue", "District of Columbia": "Blue", "Hawaii": "Blue", "Illinois": "Blue", "Maine": "Blue", "Maryland": "Blue", "Massachusetts": "Blue", "Minnesota": "Blue", "Nevada": "Blue", "New Hampshire": "Blue", "New Jersey": "Blue", "New Mexico": "Blue", "New York": "Blue", "Oregon": "Blue", "Rhode Island": "Blue", "Vermont": "Blue", "Virginia": "Blue", "Washington": "Blue", "Georgia": "Blue", "Arizona": "Blue", "Pennsylvania": "Blue", "Michigan": "Blue", "Wisconsin": "Blue", 

    # Red states (Republican-leaning in 2020)
    "Alabama": "Red", "Alaska": "Red", "Arkansas": "Red", "Florida": "Red", "Idaho": "Red", "Indiana": "Red", "Iowa": "Red", "Kansas": "Red", "Kentucky": "Red", "Louisiana": "Red", "Mississippi": "Red", "Missouri": "Red", "Montana": "Red", "Nebraska": "Red", "North Carolina": "Red", "North Dakota": "Red", "Ohio": "Red", "Oklahoma": "Red", "South Carolina": "Red", "South Dakota": "Red", "Tennessee": "Red", "Texas": "Red", "Utah": "Red", "West Virginia": "Red", "Wyoming": "Red", 

    # Territories 
    "Puerto Rico": "Territory" } 

df_state["alignment"] = df_state["state_name"].map(state_align_map) 

df_state.head() 

# Drop Puerto Rico and any non-aligned rows
df_state = df_state[df_state["alignment"].isin(["Red","Blue"])].copy() 

# Aggregate by alignment + year 
state_agg = (df_state.groupby(["year","alignment"])[["female_pct","male_pct"]].mean().reset_index().round(2))

display(state_agg) 
```

### Gender Share Across Red vs. Blue States

**Chart 1: Women Share in Blue vs Red States (2021–2024)**

```{python}
color_map = {
    "Blue": "rgba(0, 102, 204, 0.8)",
    "Red": "rgba(204, 0, 0, 0.8)"
}

fig_female = px.bar(
    state_agg,
    x="year",
    y="female_pct",
    color="alignment",
    barmode="group",
    text="female_pct",
    labels={"female_pct": "Women Share (%)"},
    title="Women Share in Blue vs Red States (2021–2024)",
    color_discrete_map=color_map
)

fig_female.update_traces(texttemplate="%{text:.2f}", textposition="outside")

fig_female.update_layout(
    xaxis_title="Year",
    yaxis_title="Women Share (%)",
    legend_title="State Alignment",
    width=800,
    height=500
)
fig_female.show()
```

The chart shows that the women’s share of the total population is consistently higher in blue states across 2021–2023, with a narrow but stable margin. In 2024, however, the pattern briefly reverses, with red states showing a slightly higher women’s share. Overall, the gap is small, but the data suggests blue states generally maintain a modestly larger female population share over most of the period.

**Chart 2: Women vs. Men Share in Red States (2021-2024)**

```{python}
stacked_data = state_agg.melt(
    id_vars=["year","alignment"],
    value_vars=["female_pct","male_pct"],
    var_name="gender",
    value_name="percentage"
)

colors_red = {
    "male_pct": "rgba(238, 195, 195, 0.8)",
    "female_pct": "rgba(204, 0, 0, 0.8)"
}

# Red States Stacked Bar Chart
df_red = stacked_data[stacked_data["alignment"] == "Red"]

fig_red = px.bar(
    df_red,
    x="year",
    y="percentage",
    color="gender",
    barmode="stack",
    text="percentage",
    labels={"percentage": "Share (%)"},
    title="Women vs. Men in Red States (2021–2024)",
    color_discrete_map=colors_red
)

fig_red.update_traces(texttemplate="%{text:.2f}", textposition="inside")
fig_red.update_layout(
    xaxis_title="Year",
    yaxis_title="Share (%)",
    legend_title="Gender",
    width=700,
    height=500
)
fig_red.show()
```

In red states, the gender balance stays remarkably steady, with women consistently making up about one-quarter of the population. The small bump in 2024 suggests a slight shift, but not significant change the overall picture. Men continue to represent the clear majority, holding roughly three-quarters of the population each year.

**Chart 3: Women vs. Men Share in Blue States (2021-2024)**

```{python}
# Blue States Stacked Bar Chart
df_blue = stacked_data[stacked_data["alignment"] == "Blue"]

colors_blue = {
    "male_pct": "rgba(185, 212, 240, 0.8)",
    "female_pct": "rgba(0, 102, 204, 0.8)"
}

fig_blue = px.bar(
    df_blue,
    x="year",
    y="percentage",
    color="gender",
    barmode="stack",
    text="percentage",
    labels={"percentage": "Share (%)"},
    title="Women vs. Men in Blue States (2021–2024)",
    color_discrete_map=colors_blue
)

fig_blue.update_traces(texttemplate="%{text:.2f}", textposition="inside")
fig_blue.update_layout(
    xaxis_title="Year",
    yaxis_title="Share (%)",
    legend_title="Gender",
    width=700,
    height=500
)
fig_blue.show()
```

Blue states show a similarly stable pattern, with women holding a slightly larger share than in red states, usually around 26 to 27%. Although there’s a minor dip in 2022 and 2023, the female share rebounds in 2024, keeping the overall trend fairly consistent. Compared to red states, blue states continue to lean just a bit more female across the full period.

**Chart 4: US Women Share by State (2024)**

```{python}
state_to_abbrev = {
    "Alabama":"AL","Alaska":"AK","Arizona":"AZ","Arkansas":"AR","California":"CA","Colorado":"CO",
    "Connecticut":"CT","Delaware":"DE","District of Columbia":"DC","Florida":"FL","Georgia":"GA",
    "Hawaii":"HI","Idaho":"ID","Illinois":"IL","Indiana":"IN","Iowa":"IA","Kansas":"KS","Kentucky":"KY",
    "Louisiana":"LA","Maine":"ME","Maryland":"MD","Massachusetts":"MA","Michigan":"MI","Minnesota":"MN",
    "Mississippi":"MS","Missouri":"MO","Montana":"MT","Nebraska":"NE","Nevada":"NV","New Hampshire":"NH",
    "New Jersey":"NJ","New Mexico":"NM","New York":"NY","North Carolina":"NC","North Dakota":"ND",
    "Ohio":"OH","Oklahoma":"OK","Oregon":"OR","Pennsylvania":"PA","Rhode Island":"RI","South Carolina":"SC",
    "South Dakota":"SD","Tennessee":"TN","Texas":"TX","Utah":"UT","Vermont":"VT","Virginia":"VA",
    "Washington":"WA","West Virginia":"WV","Wisconsin":"WI","Wyoming":"WY"
}

# Approximate state centroids (lat/lon)
state_centroids = {
    "AL":(32.806671, -86.791130),"AK":(61.370716, -152.404419),"AZ":(33.729759, -111.431221),
    "AR":(34.969704, -92.373123),"CA":(36.116203, -119.681564),"CO":(39.059811, -105.311104),
    "CT":(41.597782, -72.755371),"DE":(39.318523, -75.507141),"DC":(38.897438, -77.026817),
    "FL":(27.766279, -81.686783),"GA":(33.040619, -83.643074),"HI":(21.094318, -157.498337),
    "ID":(44.240459, -114.478828),"IL":(40.349457, -88.986137),"IN":(39.849426, -86.258278),
    "IA":(42.011539, -93.210526),"KS":(38.526600, -96.726486),"KY":(37.668140, -84.670067),
    "LA":(31.169546, -91.867805),"ME":(44.693947, -69.381927),"MD":(39.063946, -76.802101),
    "MA":(42.230171, -71.530106),"MI":(43.326618, -84.536095),"MN":(45.694454, -93.900192),
    "MS":(32.741646, -89.678696),"MO":(38.456085, -92.288368),"MT":(46.921925, -110.454353),
    "NE":(41.125370, -98.268082),"NV":(38.313515, -117.055374),"NH":(43.452492, -71.563896),
    "NJ":(40.298904, -74.521011),"NM":(34.840515, -106.248482),"NY":(42.165726, -74.948051),
    "NC":(35.630066, -79.806419),"ND":(47.528912, -99.784012),"OH":(40.388783, -82.764915),
    "OK":(35.565342, -96.928917),"OR":(44.572021, -122.070938),"PA":(40.590752, -77.209755),
    "RI":(41.680893, -71.511780),"SC":(33.856892, -80.945007),"SD":(44.299782, -99.438828),
    "TN":(35.747845, -86.692345),"TX":(31.054487, -97.563461),"UT":(40.150032, -111.862434),
    "VT":(44.045876, -72.710686),"VA":(37.769337, -78.169968),"WA":(47.400902, -121.490494),
    "WV":(38.491226, -80.954456),"WI":(44.268543, -89.616508),"WY":(42.755966, -107.302490)
}

# Choose the year to show
year_choice = 2024

df_year = df_state[df_state["year"] == year_choice].copy()
df_year["state_code"] = df_year["state_name"].map(state_to_abbrev)
df_year = df_year[df_year["state_code"].notna()].copy()

df_year["align_val"] = df_year["alignment"].map({"Red": 0, "Blue": 1})
df_year["lat"] = df_year["state_code"].map(lambda x: state_centroids[x][0])
df_year["lon"] = df_year["state_code"].map(lambda x: state_centroids[x][1])

color_map = {
    "Blue": "rgba(0, 102, 204, 0.8)",
    "Red": "rgba(204, 0, 0, 0.8)"
}

fig = go.Figure()

# Base layer
fig.add_trace(go.Choropleth(
    locations=df_year["state_code"],
    z=df_year["align_val"],
    locationmode="USA-states",
    colorscale=[[0, color_map["Red"]], [1, color_map["Blue"]]],
    showscale=False,
    marker_line_color="white",
    marker_line_width=0.5
))

# Bubble overlay: only state name visible, female_pct in hover
fig.add_trace(go.Scattergeo(
    lon=df_year["lon"],
    lat=df_year["lat"],
    text=df_year["state_code"],
    hovertext=df_year.apply(lambda r: f"{r['state_name']}<br>Female: {r['female_pct']:.1f}%", axis=1),
    marker=dict(
        size=df_year["female_pct"] * 1.5,
        color="white",
        opacity=0.85,
        line=dict(width=0.5, color="black")
    ),
    mode="markers+text",
    textposition="middle center",
    hoverinfo="text",
    name="Female Share"
))

fig.update_layout(
    title=f"US Women Share by State ({year_choice})",
    title_x=0.5,
    margin=dict(t=80),
    geo=dict(
        scope="usa",
        projection=go.layout.geo.Projection(type="albers usa"),
        showland=True,
        landcolor="rgb(240,240,240)"
    ),
    width=800,
    height=600,
    legend_title_text="Women Share"
)

fig.show()
```

The 2024 map shows that several red states have some of the largest bubbles, indicating higher female employment shares, particularly Mississippi (36%), Arkansas (34%), Louisiana (32.1%), and Wyoming (31.7%). The highest-share blue area is the District of Columbia at 35.6%. Together, these values line up with the earlier observation that in 2024, the women’s share happens to be slightly higher in red states than in blue states.

### Conclusion

Across the four-year period, blue states consistently show a slightly higher women’s share overall, but 2024 stands out with red states surpassing blue states by a narrow margin. The state-level map reinforces this shift, with several red states displaying notably high female employment shares. Taken together, these results suggest that while political alignment reflects broad trends, gender dynamics can still vary meaningfully at the state level.

</div>