For model selection or simulations, it is often needed to collect results of the same functions for many different input parameters. This can be time consuming if the job fails from time to time - always restarting it and only computing the combinations that have not yet been computed. As a helper, you can use this method.
def fill_df_with_function_results(df, kwargs, results, function, save_as, save_errors_as=None):
"""Function to fill up a dataframe with results
and save intermediate results.
Assume you have a function that takes some key word arguments