scripts/step3.py
def plot_states_median_salary(df):
    """Plots the median salary in each state using an horizontal Bar chart.

    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)

    fig = go.Figure()

    fig.add_traces(go.Bar(x=median_salaries["salary"], y=median_salaries.index, text=median_salaries["salary"],
                          orientation="h", marker={"color": median_salaries["salary"], "colorscale": "peach"}))

    fig.update_xaxes(title="Monthly Median Salary in MXN", ticks="outside", ticklen=10, tickcolor="#FFFFFF", separatethousands=True,
                     linewidth=2, showline=True, mirror=True, nticks=12, title_standoff=30, gridwidth=0.5, range=[0, median_salaries["salary"].max() * 1.1])

    fig.update_yaxes(title="", ticks="outside", ticklen=10, showgrid=False,
                     tickcolor="#FFFFFF", linewidth=2, showline=True, mirror=True)

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

    # Add final customizations.
    fig.update_layout(
        uniformtext_minsize=8,
        uniformtext_mode="hide",
        showlegend=False,
        width=1200,
        height=1400,
        font_color="#FFFFFF",
        font_size=18,
        title_text="Median Salary by State",
        title_x=0.5,
        title_y=0.96,
        margin_l=120,
        margin_b=120,
        title_font_size=30,
        paper_bgcolor="#37474f",
        plot_bgcolor="#263238"
    )

    fig.write_image("5.png")
Plots the median salary in each state using an horizontal Bar chart.

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

    
Plots the median salary in each state using an horizontal Bar chart.
Parameters

df : pandas.DataFrame
A pandas DataFrame containing job offers data.
Plots the median salary in each state using an horizontal Bar chart . Parameters df : pandas . DataFrame A pandas DataFrame containing job offers data .
def plot_states_median_salary(df):
    median_salaries = df.pivot_table(
        index="state", values="salary", aggfunc="median").sort_values("salary", ascending=False)
    fig = go.Figure()
    fig.add_traces(go.Bar(x=median_salaries["salary"], y=median_salaries.index, text=median_salaries["salary"],
                          orientation="h", marker={"color": median_salaries["salary"], "colorscale": "peach"}))
    fig.update_xaxes(title="Monthly Median Salary in MXN", ticks="outside", ticklen=10, tickcolor="#FFFFFF", separatethousands=True,
                     linewidth=2, showline=True, mirror=True, nticks=12, title_standoff=30, gridwidth=0.5, range=[0, median_salaries["salary"].max() * 1.1])
    fig.update_yaxes(title="", ticks="outside", ticklen=10, showgrid=False,
                     tickcolor="#FFFFFF", linewidth=2, showline=True, mirror=True)
    fig.update_traces(texttemplate=" %{text:,.0f}", textposition="outside")
    fig.update_layout(
        uniformtext_minsize=8,
        uniformtext_mode="hide",
        showlegend=False,
        width=1200,
        height=1400,
        font_color="#FFFFFF",
        font_size=18,
        title_text="Median Salary by State",
        title_x=0.5,
        title_y=0.96,
        margin_l=120,
        margin_b=120,
        title_font_size=30,
        paper_bgcolor="#37474f",
        plot_bgcolor="#263238"
    )
    fig.write_image("5.png")
def plot_states_median_salary ( df ) : median_salaries = df . pivot_table ( index = "state" , values = "salary" , aggfunc = "median" ) . sort_values ( "salary" , ascending = False ) fig = go . Figure ( ) fig . add_traces ( go . Bar ( x = median_salaries [ "salary" ] , y = median_salaries . index , text = median_salaries [ "salary" ] , orientation = "h" , marker = { "color" : median_salaries [ "salary" ] , "colorscale" : "peach" } ) ) fig . update_xaxes ( title = "Monthly Median Salary in MXN" , ticks = "outside" , ticklen = 10 , tickcolor = "#FFFFFF" , separatethousands = True , linewidth = 2 , showline = True , mirror = True , nticks = 12 , title_standoff = 30 , gridwidth = 0.5 , range = [ 0 , median_salaries [ "salary" ] . max ( ) * 1.1 ] ) fig . update_yaxes ( title = "" , ticks = "outside" , ticklen = 10 , showgrid = False , tickcolor = "#FFFFFF" , linewidth = 2 , showline = True , mirror = True ) fig . update_traces ( texttemplate = " %{text:,.0f}" , textposition = "outside" ) fig . update_layout ( uniformtext_minsize = 8 , uniformtext_mode = "hide" , showlegend = False , width = 1200 , height = 1400 , font_color = "#FFFFFF" , font_size = 18 , title_text = "Median Salary by State" , title_x = 0.5 , title_y = 0.96 , margin_l = 120 , margin_b = 120 , title_font_size = 30 , paper_bgcolor = "#37474f" , plot_bgcolor = "#263238" ) fig . write_image ( "5.png" )
Plots the median salary in each state using an horizontal Bar chart.
Plots the median salary in each state using an horizontal Bar chart .
"""Plots the median salary in each state using an horizontal Bar chart.

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

    """ # Add final customizations.
df