def reduce_to_only_differing_periods(df, axis):
    """Reduces a DataFrame with lots of repeating values over a time
    series to only the periods where the values have changed.
    """
    return df[df.ne(df.shift(1, axis=axis))].dropna()