import statistics


def standard_deviation(df, variable, year, mean):
    
     """
    Function to apply calculate the standard deviation of a specific
    variables mean.
    
    Uses the stqatistics package function to return the sample standard deviation
    (the square root of the sample variance).
    
    Parameters
    ----------
    df : pd.DataFrame
        dataframe containing all relevant cases.
        
    variable : str
        the variable needed to calculate its standard deviation.
        
    year : str
        specific year standard deviation wants to be calculated for.
        
    mean : int/flt
        mean used within the caluclation for standard deviation

    Returns
    -------
    sd : float 
        the result of the standard deviation calculation
    
    """
     df1 = df[(df['financial_year'] == year)]

     df1 = df1[[variable]]

     sample = (df1[variable])

     sd = statistics.stdev(sample, mean) 
    
     return sd