Label `self.items` from the values in `cols` in `self.inner_df`.
508468
def label_from_df(self, cols:IntsOrStrs=1, label_cls:Callable=None, **kwargs):
        ""
        labels = self.inner_df.iloc[:,df_names_to_idx(cols, self.inner_df)]
        assert labels.isna().sum().sum() == 0, f"You have NaN values in column(s) {cols} of your dataframe, please fix it."
        if is_listy(cols) and len(cols) > 1 and (label_cls is None or label_cls == MultiCategoryList):
            new_kwargs,label_cls = dict(one_hot=True, classes= cols),MultiCategoryList
            kwargs = {**new_kwargs, **kwargs}
        return self._label_from_list(_maybe_squeeze(labels), label_cls=label_cls, **kwargs)
545784
def grid_items(self):
        
        if list(self.keys()) == []:  return {}
        cols = self._max_cols
        return {(idx // cols, idx % cols): (key, item)
                for idx, (key, item) in enumerate(self.data.items())}
268170
def normalize_column_names(df):
    
    """
    columns = df.columns if hasattr(df, 'columns') else df
    columns = [c.lower().replace(' ', '_') for c in columns]
    return columns
1298169
def _get_label(self, axis):
        """"""

        if axis == 'x':
            colname = self.x_col
        else:  # y
            colname = self.y_col

        if colname == self._idxname:
            label = 'Index'
        else:
            col = self.tab[colname]
            if col.unit:
                label = '{0} ({1})'.format(col.name, col.unit)
            else:
                label = col.name

        return label
1209619
def stack(self, key, labels=None):
        
        rows, labels = [], labels or self.labels
        for row in self.rows:
            [rows.append((getattr(row, key), k, v)) for k, v in row.asdict().items()
             if k != key and k in labels]
        return type(self)([key, 'column', 'value']).with_rows(rows)
1019813
def label_triplets_to_df(triplets):
    

    label_df = pd.DataFrame({'label_store':np.array([t[0] for t in triplets],
                                                    dtype='int'),
                             'symbol':[t[1] for t in triplets],
                             'description':[t[2] for t in triplets]})

    label_df.set_index(label_df['label_store'].values, inplace=True)
    label_df = label_df[list(ann_label_fields)]

    return label_df
1266881
def from_df(cls, df:DataFrame, path:PathOrStr, cols:IntsOrStrs=0, folder:PathOrStr=None, suffix:str='', **kwargs)->'ItemList':
        ""
        suffix = suffix or ''
        res = super().from_df(df, path=path, cols=cols, **kwargs)
        pref = f'{res.path}{os.path.sep}'
        if folder is not None: pref += f'{folder}{os.path.sep}'
        res.items = np.char.add(np.char.add(pref, res.items.astype(str)), suffix)
        return res
892778
def extract_col(self, col):
        
        new_col = [row[col] for row in self.grid]
        return new_col
1217251
def column(self, col):
        
        if type(col) is str:
            for c in self._cols:
                if c.name == col:
                    return c
        else:
            return self._cols[col]
216722
def from_df(data_frame):
        
        labels = data_frame.keys().tolist()
        data = data_frame.values.tolist()
        return SqlTable(labels, data, "{:.3f}", "\n")
162472
def aggregated_relevant_items(raw_df):
    
    df = (
        raw_df[['idSegmento', 'idPlanilhaItens', 'VlUnitarioAprovado']]
        .groupby(by=['idSegmento', 'idPlanilhaItens'])
        .agg([np.mean, lambda x: np.std(x, ddof=0)])
    )
    df.columns = df.columns.droplevel(0)
    return (
        df
        .rename(columns={'<lambda>': 'std'})
    )
9611
def within_set(df, items=None):
    
    for k, v in items.items():
        if not df[k].isin(v).all():
            raise AssertionError
    return df
574716
def _shape(self, df):
        

        row, col = df.shape
        return row + df.columns.nlevels, col + df.index.nlevels
579284
def ncontains(self, column, value):
        
        df = self.df[self.df[column].str.contains(value) == False]
        if df is None:
            self.err("Can not select contained data")
            return
        self.df = df
48844
def from_data_frame(df, categorical=False, nb_classes=None):
    
    lp_rdd = df.rdd.map(lambda row: LabeledPoint(row.label, row.features))
    features, labels = from_labeled_point(lp_rdd, categorical, nb_classes)
    return features, labels
629414
def data_in_label(intvl_in, dtype_in_time, dtype_in_vert=False):
    """"""
    intvl_lbl = intvl_in
    time_lbl = dtype_in_time
    lbl = '_'.join(['from', intvl_lbl, time_lbl]).replace('__', '_')
    vert_lbl = dtype_in_vert if dtype_in_vert else False
    if vert_lbl:
        lbl = '_'.join([lbl, vert_lbl]).replace('__', '_')
    return lbl
982866
def keep(self, *cols):
        
        try:
            self.df = self.df[list(cols)]
        except Exception as e:
            self.err(e, "Can not remove colums")
            return
        self.ok("Setting dataframe to columns", " ".join(cols))