louismartin / email-classification-challenge

Altegard challenge in collaboration w/ Linagora
https://inclass.kaggle.com/c/master-data-science-mva-data-competition-2017
2 stars 1 forks source link

Add save_and_reload_df decorator and minor modifs #8

Closed louismartin closed 7 years ago

louismartin commented 7 years ago

Add save_and_reload_df decorator and minor modifs

Usage:

@save_and_reload_df
def my_func():
    # Create and fill the dataframe
    df = pd.DataFrame(...)
    df = ...
    return df

What the decorator does: On the first execution of the function, it will retrieve the returned dataframe and save it at data/my_func.csv. When the function is called again, if the file data/my_func.csv exists, it will not call my_func() but just read the file and return the dataframe. If one wants to compute the dataframe again, just call my_func(overwrite=True) (argument added automatically by the decorator), the decorator will call the function, save and return the new dataframe.