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

def fromcols(selection, n_sessions, eqdata, **kwargs):
    """
    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
    """
    _constfeat = kwargs.get('constfeat', True)
    _outcols = ['Constant'] if _constfeat else []
    _n_rows = len(eqdata.index)
    for _col in selection:
        _outcols += map(partial(_concat, strval=' ' + _col), range(-n_sessions + 1, 1))
    _features = pd.DataFrame(index=eqdata.index[n_sessions - 1:], columns=_outcols, dtype=np.float64)
    _offset = 0
    if _constfeat:
        _features.iloc[:, 0] = 1.
        _offset += 1
    for _col in selection:
        _values = eqdata.loc[:, _col].values
        for i in range(n_sessions):
            _features.iloc[:, _offset + i] = _values[i:_n_rows - n_sessions + i + 1]
        _offset += n_sessions
    return _features