def fromcols(selection, n_sessions, eqdata, **kwargs):
_constfeat = kwargs.get('<STR_LIT>', True)<EOL>_outcols = ['<STR_LIT>'] if _constfeat else []<EOL>_n_rows = len(eqdata.index)<EOL>for _col in selection:<EOL><INDENT>_outcols += map(partial(_concat, strval='<STR_LIT:U+0020>' + _col), range(-n_sessions + <NUM_LIT:1>, <NUM_LIT:1>))<EOL><DEDENT>_features = pd.DataFrame(index=eqdata.index[n_sessions - <NUM_LIT:1>:], columns=_outcols, dtype=np.float64)<EOL>_offset = <NUM_LIT:0><EOL>if _constfeat:<EOL><INDENT>_features.iloc[:, <NUM_LIT:0>] = <NUM_LIT:1.><EOL>_offset += <NUM_LIT:1><EOL><DEDENT>for _col in selection:<EOL><INDENT>_values = eqdata.loc[:, _col].values<EOL>for i in range(n_sessions):<EOL><INDENT>_features.iloc[:, _offset + i] = _values[i:_n_rows - n_sessions + i + <NUM_LIT:1>]<EOL><DEDENT>_offset += n_sessions<EOL><DEDENT>return _features<EOL>
Generate features from selected columns of a dataframe.

Parameters
----------
selection : list or tuple of str
    Columns to be used as features.

n_sessions : int
    Number of sessions over which to create features.

eqdata : DataFrame
    Data from which to generate feature set. Must contain
    as columns the values from which the features are to
    be generated.

constfeat : bool, optional
    Whether or not the returned features will have the constant
    feature.

Returns
----------
features : DataFrame