src/pages/dashboard.py
def plot_province_drilled(df, country):
    """
    Function computes top provinces by confirmed, deaths, recovered and active cases.

    :param df: DataFrame
    :param country: str
    :return: plotly.figure
    """
    fig = make_subplots(2, 2, subplot_titles=["Top 10 States by cases",
                                              "Top 10 States by deaths",
                                              "Top 10 States by recoveries",
                                              "Top 10 States by active cases"])
    df = df[df["Country_Region"] == country]
    df = df.groupby(["Province_State"]).agg({"Confirmed": "sum",
                                             "Deaths": "sum",
                                             "Recovered": "sum",
                                             "Active": "sum"})
    colors = px.colors.qualitative.Prism
    fig.append_trace(go.Bar(y=df["Confirmed"].nlargest(10).index,
                            x=df["Confirmed"].nlargest(10),
                            orientation='h',
                            marker=dict(color=colors),
                            hovertemplate='<br>Count: %{x:,.2f}',
                            ),
                     row=1, col=1)

    fig.append_trace(go.Bar(y=df["Deaths"].nlargest(10).index,
                            x=df["Deaths"].nlargest(10),
                            orientation='h',
                            marker=dict(color=colors),
                            hovertemplate='<br>Count: %{x:,.2f}',
                            ),
                     row=2, col=1)

    fig.append_trace(go.Bar(y=df["Recovered"].nlargest(10).index,
                            x=df["Recovered"].nlargest(10),
                            orientation='h',
                            marker=dict(color=colors),
                            hovertemplate='<br>Count: %{x:,.2f}',
                            ),
                     row=1, col=2)

    fig.append_trace(go.Bar(y=df["Active"].nlargest(10).index,
                            x=df["Active"].nlargest(10),
                            orientation='h',
                            marker=dict(color=colors),
                            hovertemplate='<br>Count: %{x:,.2f}',
                            ),
                     row=2, col=2)
    fig.update_yaxes(ticks="inside", autorange="reversed")
    fig.update_xaxes(showgrid=False)
    fig.update_traces(opacity=0.7,
                      marker_line_color='rgb(255, 255, 255)',
                      marker_line_width=2.5
                      )
    fig.update_layout(height=800, width=1200,
                      showlegend=False)

    return fig

    Function computes top provinces by confirmed, deaths, recovered and active cases.

    :param df: DataFrame
    :param country: str
    :return: plotly.figure
    
Function computes top provinces by confirmed, deaths, recovered and active cases.
Function computes top provinces by confirmed deaths recovered and active cases .
def plot_province_drilled(df, country):
    fig = make_subplots(2, 2, subplot_titles=["Top 10 States by cases",
                                              "Top 10 States by deaths",
                                              "Top 10 States by recoveries",
                                              "Top 10 States by active cases"])
    df = df[df["Country_Region"] == country]
    df = df.groupby(["Province_State"]).agg({"Confirmed": "sum",
                                             "Deaths": "sum",
                                             "Recovered": "sum",
                                             "Active": "sum"})
    colors = px.colors.qualitative.Prism
    fig.append_trace(go.Bar(y=df["Confirmed"].nlargest(10).index,
                            x=df["Confirmed"].nlargest(10),
                            orientation='h',
                            marker=dict(color=colors),
                            hovertemplate='<br>Count: %{x:,.2f}',
                            ),
                     row=1, col=1)
    fig.append_trace(go.Bar(y=df["Deaths"].nlargest(10).index,
                            x=df["Deaths"].nlargest(10),
                            orientation='h',
                            marker=dict(color=colors),
                            hovertemplate='<br>Count: %{x:,.2f}',
                            ),
                     row=2, col=1)
    fig.append_trace(go.Bar(y=df["Recovered"].nlargest(10).index,
                            x=df["Recovered"].nlargest(10),
                            orientation='h',
                            marker=dict(color=colors),
                            hovertemplate='<br>Count: %{x:,.2f}',
                            ),
                     row=1, col=2)
    fig.append_trace(go.Bar(y=df["Active"].nlargest(10).index,
                            x=df["Active"].nlargest(10),
                            orientation='h',
                            marker=dict(color=colors),
                            hovertemplate='<br>Count: %{x:,.2f}',
                            ),
                     row=2, col=2)
    fig.update_yaxes(ticks="inside", autorange="reversed")
    fig.update_xaxes(showgrid=False)
    fig.update_traces(opacity=0.7,
                      marker_line_color='rgb(255, 255, 255)',
                      marker_line_width=2.5
                      )
    fig.update_layout(height=800, width=1200,
                      showlegend=False)
    return fig
def plot_province_drilled ( df , country ) : fig = make_subplots ( 2 , 2 , subplot_titles = [ "Top 10 States by cases" , "Top 10 States by deaths" , "Top 10 States by recoveries" , "Top 10 States by active cases" ] ) df = df [ df [ "Country_Region" ] == country ] df = df . groupby ( [ "Province_State" ] ) . agg ( { "Confirmed" : "sum" , "Deaths" : "sum" , "Recovered" : "sum" , "Active" : "sum" } ) colors = px . colors . qualitative . Prism fig . append_trace ( go . Bar ( y = df [ "Confirmed" ] . nlargest ( 10 ) . index , x = df [ "Confirmed" ] . nlargest ( 10 ) , orientation = 'h' , marker = dict ( color = colors ) , hovertemplate = '<br>Count: %{x:,.2f}' , ) , row = 1 , col = 1 ) fig . append_trace ( go . Bar ( y = df [ "Deaths" ] . nlargest ( 10 ) . index , x = df [ "Deaths" ] . nlargest ( 10 ) , orientation = 'h' , marker = dict ( color = colors ) , hovertemplate = '<br>Count: %{x:,.2f}' , ) , row = 2 , col = 1 ) fig . append_trace ( go . Bar ( y = df [ "Recovered" ] . nlargest ( 10 ) . index , x = df [ "Recovered" ] . nlargest ( 10 ) , orientation = 'h' , marker = dict ( color = colors ) , hovertemplate = '<br>Count: %{x:,.2f}' , ) , row = 1 , col = 2 ) fig . append_trace ( go . Bar ( y = df [ "Active" ] . nlargest ( 10 ) . index , x = df [ "Active" ] . nlargest ( 10 ) , orientation = 'h' , marker = dict ( color = colors ) , hovertemplate = '<br>Count: %{x:,.2f}' , ) , row = 2 , col = 2 ) fig . update_yaxes ( ticks = "inside" , autorange = "reversed" ) fig . update_xaxes ( showgrid = False ) fig . update_traces ( opacity = 0.7 , marker_line_color = 'rgb(255, 255, 255)' , marker_line_width = 2.5 ) fig . update_layout ( height = 800 , width = 1200 , showlegend = False ) return fig
Function computes top provinces by confirmed, deaths, recovered and active cases.
Function computes top provinces by confirmed deaths recovered and active cases .
"""
    Function computes top provinces by confirmed, deaths, recovered and active cases.

    :param df: DataFrame
    :param country: str
    :return: plotly.figure
    """
None
df
None
country
None