<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_qout_index(self, river_index_array=None, date_search_start=None, date_search_end=None, time_index_start=None, time_index_end=None, time_index=None, time_index_array=None, daily=False, pd_filter=None, filter_mode="mean", as_dataframe=False):
 """ This method extracts streamflow data by river index. It allows for extracting single or multiple river streamflow arrays It has options to extract by date or by date index. See: :meth:`RAPIDpy.RAPIDDataset.get_qout` """

        if river_index_array is not None:
            if hasattr(river_index_array, "__len__"):
                if len(river_index_array) == 1:
                    river_index_array = river_index_array[0]

        if time_index_array is None:
            time_index_array = self.get_time_index_range(date_search_start,
                                                         date_search_end,
                                                         time_index_start,
                                                         time_index_end,
                                                         time_index)

        qout_variable = self.qout_nc.variables[self.q_var_name]
        qout_dimensions = qout_variable.dimensions
        if qout_dimensions[0].lower() == 'time' and \
                qout_dimensions[1].lower() == self.river_id_dimension.lower():
            if time_index_array is not None and river_index_array is not None:
                streamflow_array = qout_variable[time_index_array,
                                                 river_index_array].transpose()
            elif time_index_array is not None:
                streamflow_array = qout_variable[time_index_array, :] \
                                   .transpose()
            elif river_index_array is not None:
                streamflow_array = qout_variable[:, river_index_array] \
                                   .transpose()
            else:
                streamflow_array = qout_variable[:].transpose()
        elif qout_dimensions[1].lower() == 'time' and \
                qout_dimensions[0].lower() == self.river_id_dimension.lower():
            if time_index_array is not None and river_index_array is not None:
                streamflow_array = qout_variable[river_index_array,
                                                 time_index_array]
            elif time_index_array is not None:
                streamflow_array = qout_variable[:, time_index_array]
            elif river_index_array is not None:
                streamflow_array = qout_variable[river_index_array, :]
            else:
                streamflow_array = qout_variable[:]
        else:
            raise Exception("Invalid RAPID Qout file dimensions ...")

        if daily:
            pd_filter = "D"

        if pd_filter is not None or as_dataframe:
            time_array = self.get_time_array(return_datetime=True,
                                             time_index_array=time_index_array)
            qout_df = pd.DataFrame(streamflow_array.T, index=time_array)

            if pd_filter is not None:
                qout_df = qout_df.resample(pd_filter)
                if filter_mode == "mean":
                    qout_df = qout_df.mean()
                elif filter_mode == "max":
                    qout_df = qout_df.max()
                else:
                    raise Exception("Invalid filter_mode ...")

            if as_dataframe:
                return qout_df

            streamflow_array = qout_df.as_matrix().T

            if streamflow_array.ndim > 0 and streamflow_array.shape[0] == 1:
                streamflow_array = streamflow_array[0]

        return streamflow_array