def time_series(timefile, colnames):
if not timefile.is_file():<EOL><INDENT>return None<EOL><DEDENT>data = pd.read_csv(timefile, delim_whitespace=True, dtype=str,<EOL>header=None, skiprows=<NUM_LIT:1>, index_col=<NUM_LIT:0>,<EOL>engine='<STR_LIT:c>', memory_map=True,<EOL>error_bad_lines=False, warn_bad_lines=False)<EOL>data = data.apply(pd.to_numeric, raw=True, errors='<STR_LIT>')<EOL>rows_to_del = []<EOL>irow = len(data) - <NUM_LIT:1><EOL>while irow > <NUM_LIT:0>:<EOL><INDENT>iprev = irow - <NUM_LIT:1><EOL>while iprev >= <NUM_LIT:0> and data.index[irow] <= data.index[iprev]:<EOL><INDENT>rows_to_del.append(iprev)<EOL>iprev -= <NUM_LIT:1><EOL><DEDENT>irow = iprev<EOL><DEDENT>if rows_to_del:<EOL><INDENT>rows_to_keep = set(range(len(data))) - set(rows_to_del)<EOL>data = data.take(list(rows_to_keep), convert=False)<EOL><DEDENT>ncols = data.shape[<NUM_LIT:1>]<EOL>_tidy_names(colnames, ncols)<EOL>data.columns = colnames<EOL>return data<EOL>
Read temporal series text file.

    If :data:`colnames` is too long, it will be truncated. If it is too short,
    additional numeric column names from 0 to N-1 will be attributed to the N
    extra columns present in :data:`timefile`.

    Args:
        timefile (:class:`pathlib.Path`): path of the time.dat file.
        colnames (list of names): names of the variables expected in
            :data:`timefile` (may be modified).

    Returns:
        :class:`pandas.DataFrame`:
            Time series, with the variables in columns and the time steps in
            rows.