How to use the dtale.utils.grid_columns function in dtale

To help you get started, we’ve selected a few dtale examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github man-group / dtale / dtale / views.py View on Github external
for group_val, grp in data.groupby(group_col):
            group_val = '/'.join([
                group_fmts[gc](gv) for gv, gc in zip(make_list(group_val), group_col)
            ])
            ret_data['data'][group_val] = f.format_lists(grp)
        return ret_data
    data = data[[x, y]].sort_values(x)
    data.columns = [x_col, y_col]
    if agg is not None:
        data = data.groupby(x_col)
        data = getattr(data, agg)().reset_index()

    if any(data[x_col].duplicated()):
        raise Exception('{} contains duplicates, please specify group or additional filtering'.format(x))
    f = grid_formatter(
        grid_columns(data), overrides={'D': lambda f, i, c: f.add_timestamp(i, c)}, nan_display=None
    )
    y_fmt = next((fmt for _, name, fmt in f.fmts if name == y_col), None)
    ret_data = dict(
        data={str('all'): f.format_lists(data)},
        min=y_fmt(data[y_col].min(), None),
        max=y_fmt(data[y_col].max(), None)
    )
    return ret_data
github man-group / dtale / dtale / views.py View on Github external
if group_col is not None:
        data = data[group_col + [x, y]].sort_values(group_col + [x])

        data.columns = group_col + [x_col, y_col]
        if agg is not None:
            data = data.groupby(group_col + [x_col])
            data = getattr(data, agg)().reset_index()
        max_groups = 15
        if len(data[group_col].drop_duplicates()) > max_groups:
            msg = (
                'Group ({}) contains more than {} unique values, please add additional filter'
                ' or else chart will be unreadable'
            ).format(', '.join(group_col), max_groups)
            raise Exception(msg)
        f = grid_formatter(
            grid_columns(data[[x_col, y_col]]), overrides={'D': lambda f, i, c: f.add_timestamp(i, c)}, nan_display=None
        )
        y_fmt = next((fmt for _, name, fmt in f.fmts if name == y_col), None)
        ret_data = dict(data={}, min=y_fmt(data[y_col].min(), None), max=y_fmt(data[y_col].max(), None))
        dtypes = get_dtypes(data)
        group_fmts = {c: find_dtype_formatter(dtypes[c]) for c in group_col}
        for group_val, grp in data.groupby(group_col):
            group_val = '/'.join([
                group_fmts[gc](gv) for gv, gc in zip(make_list(group_val), group_col)
            ])
            ret_data['data'][group_val] = f.format_lists(grp)
        return ret_data
    data = data[[x, y]].sort_values(x)
    data.columns = [x_col, y_col]
    if agg is not None:
        data = data.groupby(x_col)
        data = getattr(data, agg)().reset_index()