(df)
return pd.DataFrame(data)
Convert to the problem regression form.

    The problem is that using parameters among continuous 9 hours to predict PM2.5 on next hour.

    Args:
        df (pd.Dataframe): `index` is datetime
                           `columns` include parameters AMB_TEMP, CH4, CO,..., PM2.5,..., WS_HR
Convert to the problem regression form.
Convert to the problem regression form .
def _convert_to_problem_regression_form(df):
    """Convert to the problem regression form.

    The problem is that using parameters among continuous 9 hours to predict PM2.5 on next hour.

    Args:
        df (pd.Dataframe): `index` is datetime
                           `columns` include parameters AMB_TEMP, CH4, CO,..., PM2.5,..., WS_HR

    """
    data = OrderedDict()

    # create columns of `data`
    param_list = df.columns.tolist()
    for i in range(9):
        for param in param_list:
            data['{:02d}h__{}'.format(i+1, param)] = []
    data['10h__PM2.5'] = []

    # add content into `data`
    datetime_list = df.index
    d1h = timedelta(hours=1)
    for m in pd.unique(datetime_list.month):
        for timestamp in (df.loc[df.index.month == m, :]).index:
            start, end = timestamp, timestamp + 9*d1h
            sub_df = df.loc[(start <= df.index) & (df.index <= end), :]
            if sub_df.shape[0] == 10:
                for i in range(9):
                    for param in param_list:
                        data['{:02d}h__{}'.format(i+1, param)].append(
                            sub_df.loc[timestamp+i*d1h, param])
                data['10h__PM2.5'].append(sub_df.loc[timestamp + 9 * d1h, 'PM2.5'])

    return pd.DataFrame(data)
def _convert_to_problem_regression_form ( df ) : data = OrderedDict ( ) # create columns of `data` param_list = df . columns . tolist ( ) for i in range ( 9 ) : for param in param_list : data [ '{:02d}h__{}' . format ( i + 1 , param ) ] = [ ] data [ '10h__PM2.5' ] = [ ] # add content into `data` datetime_list = df . index d1h = timedelta ( hours = 1 ) for m in pd . unique ( datetime_list . month ) : for timestamp in ( df . loc [ df . index . month == m , : ] ) . index : start , end = timestamp , timestamp + 9 * d1h sub_df = df . loc [ ( start <= df . index ) & ( df . index <= end ) , : ] if sub_df . shape [ 0 ] == 10 : for i in range ( 9 ) : for param in param_list : data [ '{:02d}h__{}' . format ( i + 1 , param ) ] . append ( sub_df . loc [ timestamp + i * d1h , param ] ) data [ '10h__PM2.5' ] . append ( sub_df . loc [ timestamp + 9 * d1h , 'PM2.5' ] ) return pd . DataFrame ( data )