def small_sample(df):
    """output a random sample data csv file for smaller sample analysis"""
    df_s = df.groupby(['CountryID', 'SchoolID']).apply(lambda x: x.sample(
        frac=0.5, random_state=999)).reset_index(drop=True)
    return df_s.to_csv('sample data.csv', encoding='utf-8')
