How to use the ipysheet.sheet.Sheet function in ipysheet

To help you get started, we’ve selected a few ipysheet 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 QuantStack / ipysheet / ipysheet / easy.py View on Github external
>>> assert sheet1 is ipysheet.sheet('key1')
    >>> assert sheet1 is ipysheet.current()

    Parameters
    ----------
    key : any
        If not used before, register the sheet under this key. If used before, return the previous `Sheet` instance
        registered with this key.

    Returns
    -------
    Sheet
        The new sheet, or if key is given, the previously created sheet registered with this key.
    """
    global _last_sheet
    if isinstance(key, Sheet):
        _last_sheet = key
    elif key is None or key not in _sheets:
        _last_sheet = cls(rows=rows, columns=columns, column_width=column_width,
                          row_headers=row_headers, column_headers=column_headers,
                          stretch_headers=stretch_headers, **kwargs)
        if key is not None:
            _sheets[key] = _last_sheet
    else:
        _last_sheet = _sheets[key]
    return _last_sheet
github QuantStack / ipysheet / ipysheet / pandas_loader.py View on Github external
idx = 0
    for c in columns:
        arr = np.array(dataframe[c].values)
        cells.append(Cell(
            value=_get_cell_value(arr),
            row_start=0,
            row_end=len(rows) - 1,
            column_start=idx,
            column_end=idx,
            type=_get_cell_type(arr.dtype),
            squeeze_row=False,
            squeeze_column=True
        ))
        idx += 1

    return Sheet(
        rows=len(rows),
        columns=len(columns),
        cells=cells,
        row_headers=[str(header) for header in rows],
        column_headers=[str(header) for header in columns]
    )
github QuantStack / ipysheet / ipysheet / easy.py View on Github external
def sheet(key=None, rows=5, columns=5, column_width=None, row_headers=True, column_headers=True,
          stretch_headers='all', cls=Sheet, **kwargs):
    """Creates a new Sheet instance or retrieves one registered with key, and sets this as the 'current'.

    If the key argument is given, and no sheet is created before with this key, it will be registered under
    this key. If this function is called again with the same key argument, that :ref:`Sheet` instance
    will be returned.

    Example:

    >>> sheet1 = ipysheet.sheet('key1')
    >>> sheet2 = ipysheet.sheet('key2')
    >>> assert sheet2 is ipysheet.current()
    >>> assert sheet1 is ipysheet.sheet('key1')
    >>> assert sheet1 is ipysheet.current()

    Parameters
    ----------