def take_sample(df):
    """ If input dataframe has >300 rows, take 300 at random in a new dataramef.
    """
    if len(df) < 300:
        sample_limit = len(df)
    else:
        sample_limit = 300
    sample_df = df.sample(n=sample_limit)
    return sample_df