def feature_engineering(df):
    """Add statistics to raw data to analyze changes across time"""

    # day-to-day change  
    df['result_count_absolute_change'] = df.groupby('keyword').results_count.diff().reset_index(drop=True) # day-to-day absolute change
    df['result_count_relative_change'] = (df.result_count_absolute_change/df.results_count*100) # day-to-day relative change 

    # overall days keyword already tracked
    df['start_date'], df['end_date'] = df.groupby('keyword').query_timestamp.transform('min'), df.groupby('keyword').query_timestamp.transform('max')
    df['days_tracked'] = (df['end_date']-df['start_date']).dt.days
    
    return df