src/pages/dashboard.py
def plot_province(df, country):
    """
    Function plots the map of a country with the state/county level information as a hover.

    :param df: DataFrame
    :param country: str
    :return: plotly.figure
    """
    fig = None
    df = df[df["Country_Region"] == country]
    if df["Province_State"].isnull().all():
        st.info("Sorry we do not have province/state level information for {}".format(country))
    else:
        df.rename(columns={"Lat": "lat",
                           "Long_": "lon",
                           "Admin2": "City"}, inplace=True)
        df["City"].fillna("Not Available", inplace=True)
        df.loc[:, 'Scaled Confirmed'] = df.loc[:, 'Confirmed'].apply(lambda s: np.log(s))
        df.loc[:, 'Scaled Confirmed'] = df.loc[:, 'Scaled Confirmed'].apply(
            lambda s: 0 if s == -np.inf else s)
        df["Province_State"].fillna("Not Available", inplace=True)
        temp = df[["lat", "lon"]]
        temp.dropna(inplace=True)
        with open("src/pages/utils/tokens/.mapbox_token") as tfile:
            token = tfile.read()
        fig = px.scatter_mapbox(df, lat="lat", lon="lon", zoom=3, height=600, width=800,
                                size="Scaled Confirmed",
                                color="Incident_Rate",
                                color_continuous_scale=px.colors.sequential.Hot,
                                hover_name="Combined_Key", hover_data=["City", "Province_State", "Confirmed",
                                                                       "Deaths", "Recovered"])
        fig.update_traces(opacity=0.7)
        fig.update_layout(mapbox_style="dark", height=1000, width=1000, mapbox_accesstoken=token)
        fig.update_layout(margin={"r": 0, "t": 0, "l": 0, "b": 0})

    return fig

    Function plots the map of a country with the state/county level information as a hover.

    :param df: DataFrame
    :param country: str
    :return: plotly.figure
    
Function plots the map of a country with the state/county level information as a hover.
Function plots the map of a country with the state / county level information as a hover .
def plot_province(df, country):
    fig = None
    df = df[df["Country_Region"] == country]
    if df["Province_State"].isnull().all():
        st.info("Sorry we do not have province/state level information for {}".format(country))
    else:
        df.rename(columns={"Lat": "lat",
                           "Long_": "lon",
                           "Admin2": "City"}, inplace=True)
        df["City"].fillna("Not Available", inplace=True)
        df.loc[:, 'Scaled Confirmed'] = df.loc[:, 'Confirmed'].apply(lambda s: np.log(s))
        df.loc[:, 'Scaled Confirmed'] = df.loc[:, 'Scaled Confirmed'].apply(
            lambda s: 0 if s == -np.inf else s)
        df["Province_State"].fillna("Not Available", inplace=True)
        temp = df[["lat", "lon"]]
        temp.dropna(inplace=True)
        with open("src/pages/utils/tokens/.mapbox_token") as tfile:
            token = tfile.read()
        fig = px.scatter_mapbox(df, lat="lat", lon="lon", zoom=3, height=600, width=800,
                                size="Scaled Confirmed",
                                color="Incident_Rate",
                                color_continuous_scale=px.colors.sequential.Hot,
                                hover_name="Combined_Key", hover_data=["City", "Province_State", "Confirmed",
                                                                       "Deaths", "Recovered"])
        fig.update_traces(opacity=0.7)
        fig.update_layout(mapbox_style="dark", height=1000, width=1000, mapbox_accesstoken=token)
        fig.update_layout(margin={"r": 0, "t": 0, "l": 0, "b": 0})
    return fig
def plot_province ( df , country ) : fig = None df = df [ df [ "Country_Region" ] == country ] if df [ "Province_State" ] . isnull ( ) . all ( ) : st . info ( "Sorry we do not have province/state level information for {}" . format ( country ) ) else : df . rename ( columns = { "Lat" : "lat" , "Long_" : "lon" , "Admin2" : "City" } , inplace = True ) df [ "City" ] . fillna ( "Not Available" , inplace = True ) df . loc [ : , 'Scaled Confirmed' ] = df . loc [ : , 'Confirmed' ] . apply ( lambda s : np . log ( s ) ) df . loc [ : , 'Scaled Confirmed' ] = df . loc [ : , 'Scaled Confirmed' ] . apply ( lambda s : 0 if s == - np . inf else s ) df [ "Province_State" ] . fillna ( "Not Available" , inplace = True ) temp = df [ [ "lat" , "lon" ] ] temp . dropna ( inplace = True ) with open ( "src/pages/utils/tokens/.mapbox_token" ) as tfile : token = tfile . read ( ) fig = px . scatter_mapbox ( df , lat = "lat" , lon = "lon" , zoom = 3 , height = 600 , width = 800 , size = "Scaled Confirmed" , color = "Incident_Rate" , color_continuous_scale = px . colors . sequential . Hot , hover_name = "Combined_Key" , hover_data = [ "City" , "Province_State" , "Confirmed" , "Deaths" , "Recovered" ] ) fig . update_traces ( opacity = 0.7 ) fig . update_layout ( mapbox_style = "dark" , height = 1000 , width = 1000 , mapbox_accesstoken = token ) fig . update_layout ( margin = { "r" : 0 , "t" : 0 , "l" : 0 , "b" : 0 } ) return fig
Function plots the map of a country with the state/county level information as a hover.
Function plots the map of a country with the state / county level information as a hover .
"""
    Function plots the map of a country with the state/county level information as a hover.

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