docs: def compute_route_stats(
      feed: "Feed",
      trip_stats_subset: DataFrame,
      dates: List[str],
      headway_start_time: str = "07:00:00",
      headway_end_time: str = "19:00:00",
      *,
      split_directions: bool = False,
  ) -> DataFrame:
      """
      Compute route stats for all the trips that lie in the given subset
      of trip stats and that start on the given dates.
  
      Parameters
      ----------
      feed : Feed
      trip_stats_subset : DataFrame
          Slice of the output of :func:`.trips.compute_trip_stats`
      dates : string or list
          A YYYYMMDD date string or list thereof indicating the date(s)
          for which to compute stats
      split_directions : boolean
          If ``True``, then separate the stats by trip direction (0 or 1);
          otherwise aggregate trips visiting from both directions
      headway_start_time : string
          HH:MM:SS time string indicating the start time for computing
          headway stats
      headway_end_time : string
          HH:MM:SS time string indicating the end time for computing
          headway stats
  
      Returns
      -------
      DataFrame
          Columns are
  
          - ``'date'``
          - the columns listed in :func:``compute_route_stats_base``
  
          Dates with no trip activity will have null stats.
          Exclude dates that lie outside of the Feed's date range.
          If all the dates given lie outside of the Feed's date range,
          then return an empty DataFrame.
  
      Notes
      -----
      - The route stats for date d contain stats for trips that start on
        date d only and ignore trips that start on date d-1 and end on
        date d
      - Assume the following feed attributes are not ``None``:
  
          * Those used in :func:`.helpers.compute_route_stats_base`
  
      - Raise a ValueError if ``split_directions`` and no non-NaN
        direction ID values present
  
      """
      dates = feed.restrict_dates(dates)
      if not dates:
          return pd.DataFrame()
  
      ts = trip_stats_subset.copy()
      activity = feed.compute_trip_activity(dates)
  
      # Collect stats for each date, memoizing stats by trip ID sequence
      # to avoid unnecessary recomputations.
      # Store in dictionary of the form
      # trip ID sequence ->
      # [stats DataFarme, date list that stats apply]
      stats_and_dates_by_ids = {}
      cols = [
          "route_id",
          "route_short_name",
          "route_type",
          "num_trips",
          "num_trip_ends",
          "num_trip_starts",
          "is_bidirectional",
          "is_loop",
          "start_time",
          "end_time",
          "max_headway",
          "min_headway",
          "mean_headway",
          "peak_num_trips",
          "peak_start_time",
          "peak_end_time",
          "service_duration",
          "service_distance",
          "service_speed",
          "mean_trip_distance",
          "mean_trip_duration",
      ]
      if split_directions:
          cols.append("direction_id")
      null_stats = pd.DataFrame(
          OrderedDict([(c, np.nan) for c in cols]), index=[0]
      )
      for date in dates:
          ids = tuple(activity.loc[activity[date] > 0, "trip_id"])
          if ids in stats_and_dates_by_ids:
              # Append date to date list
              stats_and_dates_by_ids[ids][1].append(date)
          elif not ids:
              # Null stats
              stats_and_dates_by_ids[ids] = [null_stats, [date]]
          else:
              # Compute stats
              t = ts[ts["trip_id"].isin(ids)].copy()
              stats = compute_route_stats_base(
                  t,
                  split_directions=split_directions,
                  headway_start_time=headway_start_time,
                  headway_end_time=headway_end_time,
              )
  
              # Remember stats
              stats_and_dates_by_ids[ids] = [stats, [date]]
  
      # Assemble stats into DataFrame
      frames = []
      for stats, dates_ in stats_and_dates_by_ids.values():
          for date in dates_:
              f = stats.copy()
              f["date"] = date
              frames.append(f)
      f = (
          pd.concat(frames)
          .sort_values(["date", "route_id"])
          .reset_index(drop=True)
      )
  
      return f