scripts/step3.py
def plot_median_salary_map(df):
    """Plots the median salary by state in a Choropleth map.

    Parameters
    ----------
    df : pandas.DataFrame
        A pandas DataFrame containing job offers data.

    """

    median_salaries = df.pivot_table(
        index="state", values="salary", aggfunc="median").sort_values("salary", ascending=False)

    geojson = json.loads(open("mexico.json", "r", encoding="utf-8").read())

    fig = go.Figure()

    fig.add_traces(go.Choropleth(geojson=geojson,
                                 locations=median_salaries.index,
                                 z=median_salaries["salary"],
                                 featureidkey="properties.ADMIN_NAME",
                                 marker_line_color="#FFFFFF",
                                 marker_line_width=1,
                                 colorbar_outlinecolor="#FFFFFF",
                                 colorbar_outlinewidth=1.75,
                                 colorbar_separatethousands=True,
                                 colorbar_ticks="outside",
                                 colorbar_ticklen=10,
                                 colorbar_tickcolor="#FFFFFF"))

    fig.update_geos(fitbounds="locations",
                    showocean=True, oceancolor="#263238",
                    showcountries=True, countrycolor="#FFFFFF", countrywidth=1.5,
                    framewidth=2, framecolor="#FFFFFF",
                    showlakes=False,
                    landcolor="#1B2327")

    # Add final customizations.
    fig.update_layout(
        title_text="Median Salary by State",
        title_x=0.5,
        title_y=0.96,
        title_font_size=30,
        font_color="#FFFFFF",
        margin={"r": 50, "t": 50, "l": 50, "b": 50},
        width=1200,
        height=650,
        paper_bgcolor="#37474f",
    )

    fig.write_image("6.png")
Plots the median salary by state in a Choropleth map.

    Parameters
    ----------
    df : pandas.DataFrame
        A pandas DataFrame containing job offers data.

    
Plots the median salary by state in a Choropleth map.
Parameters

df : pandas.DataFrame
A pandas DataFrame containing job offers data.
Plots the median salary by state in a Choropleth map . Parameters df : pandas . DataFrame A pandas DataFrame containing job offers data .
def plot_median_salary_map(df):
    median_salaries = df.pivot_table(
        index="state", values="salary", aggfunc="median").sort_values("salary", ascending=False)
    geojson = json.loads(open("mexico.json", "r", encoding="utf-8").read())
    fig = go.Figure()
    fig.add_traces(go.Choropleth(geojson=geojson,
                                 locations=median_salaries.index,
                                 z=median_salaries["salary"],
                                 featureidkey="properties.ADMIN_NAME",
                                 marker_line_color="#FFFFFF",
                                 marker_line_width=1,
                                 colorbar_outlinecolor="#FFFFFF",
                                 colorbar_outlinewidth=1.75,
                                 colorbar_separatethousands=True,
                                 colorbar_ticks="outside",
                                 colorbar_ticklen=10,
                                 colorbar_tickcolor="#FFFFFF"))
    fig.update_geos(fitbounds="locations",
                    showocean=True, oceancolor="#263238",
                    showcountries=True, countrycolor="#FFFFFF", countrywidth=1.5,
                    framewidth=2, framecolor="#FFFFFF",
                    showlakes=False,
                    landcolor="#1B2327")
    fig.update_layout(
        title_text="Median Salary by State",
        title_x=0.5,
        title_y=0.96,
        title_font_size=30,
        font_color="#FFFFFF",
        margin={"r": 50, "t": 50, "l": 50, "b": 50},
        width=1200,
        height=650,
        paper_bgcolor="#37474f",
    )
    fig.write_image("6.png")
def plot_median_salary_map ( df ) : median_salaries = df . pivot_table ( index = "state" , values = "salary" , aggfunc = "median" ) . sort_values ( "salary" , ascending = False ) geojson = json . loads ( open ( "mexico.json" , "r" , encoding = "utf-8" ) . read ( ) ) fig = go . Figure ( ) fig . add_traces ( go . Choropleth ( geojson = geojson , locations = median_salaries . index , z = median_salaries [ "salary" ] , featureidkey = "properties.ADMIN_NAME" , marker_line_color = "#FFFFFF" , marker_line_width = 1 , colorbar_outlinecolor = "#FFFFFF" , colorbar_outlinewidth = 1.75 , colorbar_separatethousands = True , colorbar_ticks = "outside" , colorbar_ticklen = 10 , colorbar_tickcolor = "#FFFFFF" ) ) fig . update_geos ( fitbounds = "locations" , showocean = True , oceancolor = "#263238" , showcountries = True , countrycolor = "#FFFFFF" , countrywidth = 1.5 , framewidth = 2 , framecolor = "#FFFFFF" , showlakes = False , landcolor = "#1B2327" ) fig . update_layout ( title_text = "Median Salary by State" , title_x = 0.5 , title_y = 0.96 , title_font_size = 30 , font_color = "#FFFFFF" , margin = { "r" : 50 , "t" : 50 , "l" : 50 , "b" : 50 } , width = 1200 , height = 650 , paper_bgcolor = "#37474f" , ) fig . write_image ( "6.png" )
Plots the median salary by state in a Choropleth map.
Plots the median salary by state in a Choropleth map .
"""Plots the median salary by state in a Choropleth map.

    Parameters
    ----------
    df : pandas.DataFrame
        A pandas DataFrame containing job offers data.

    """ # Add final customizations.
df