def _filter_by_day_of_week(data, day_start, day_end):
    """Filter data by day of week to get:
     day_start <= data.index.dayofweek <= day_end

     It follows from the above that day_start should be <= day_end.

     Note from the Pandas documentation that Monday = 0, Sunday = 6:
     https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DatetimeIndex.html

     :param data: Pandas DataFrame or Series, index by time.
     :param day_start: Integer, representing the starting day.
     :param day_end: Integer, representing the ending day.

     NOTE: This method is "private" as inputs won't be checked. In most
     cases you'll want to sipmly use filter_by_weekday or
     filter_by_weekend.
     """
    dow = data.index.dayofweek
    return data.loc[(dow >= day_start) & (dow <= day_end), :]