def save_func(directory, fit_name, filetype, df, comp=''):
    """
    Function that saves fitting results to directory

    :param directory: str
        input directory for the location of the save file

    :param fit_name: str
        input name of file to be saved

    :param filetype: str
        input filetype to be saved

    :param df: pd.DataFrame
        dataframe to be converted into .csv or .json

    :param comp: str
        Used to differentiate files when multiple component fitting results are saved

    """
    fit_string = directory + fit_name + comp + filetype

    file_conv_fit = {
        '.csv': df.to_csv(fit_string),
        '.json': df.to_json(fit_string)
    }
    print("File saved to directory")
    return file_conv_fit[filetype]