How to use the ipysheet.column 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 / test_all.py View on Github external
row.value = [0, 1, 2]
    with pytest.raises(ValueError):
        row.value = 1
    row.value = [0, 1, 2, 4]
    assert row.value == [0, 1, 2, 4]

    ipysheet.column(0, [0, 1, 2])
    ipysheet.column(0, [0, 1])
    ipysheet.column(0, [0, 1], row_end=1)
    ipysheet.column(0, [0, 1], row_start=1)
    with pytest.raises(ValueError):
        ipysheet.column(0, [0, 1, 2, 3])
    with pytest.raises(ValueError):
        ipysheet.column(0, [0, 1], row_end=0)
    with pytest.raises(ValueError):
        ipysheet.column(0, [0, 1, 2, 4], row_start=1)

    col = ipysheet.column(0, [0, 1, 2])
    with pytest.raises(ValueError):
        col.value = [0, 1]
    with pytest.raises(ValueError):
        col.value = 1
    col.value = [0, 1, 3]
    assert col.value == [0, 1, 3]
github QuantStack / ipysheet / ipysheet / test_all.py View on Github external
with pytest.raises(ValueError):
        ipysheet.row(0, [0, 1, 2, 4, 5])
    with pytest.raises(ValueError):
        ipysheet.row(0, [0, 1], column_end=3)
    with pytest.raises(ValueError):
        ipysheet.row(0, [0, 1, 2, 4], column_start=1)

    row = ipysheet.row(0, [0, 1, 2, 3])
    with pytest.raises(ValueError):
        row.value = [0, 1, 2]
    with pytest.raises(ValueError):
        row.value = 1
    row.value = [0, 1, 2, 4]
    assert row.value == [0, 1, 2, 4]

    ipysheet.column(0, [0, 1, 2])
    ipysheet.column(0, [0, 1])
    ipysheet.column(0, [0, 1], row_end=1)
    ipysheet.column(0, [0, 1], row_start=1)
    with pytest.raises(ValueError):
        ipysheet.column(0, [0, 1, 2, 3])
    with pytest.raises(ValueError):
        ipysheet.column(0, [0, 1], row_end=0)
    with pytest.raises(ValueError):
        ipysheet.column(0, [0, 1, 2, 4], row_start=1)

    col = ipysheet.column(0, [0, 1, 2])
    with pytest.raises(ValueError):
        col.value = [0, 1]
    with pytest.raises(ValueError):
        col.value = 1
    col.value = [0, 1, 3]
github QuantStack / ipysheet / ipysheet / test_all.py View on Github external
transpose=False
    )

    df = ipysheet.to_dataframe(sheet)
    assert np.all(df['t0'].tolist() == [2,   1,   2,   2])
    assert np.all(df['t1'].tolist() == [34,  1,   2,   0])
    assert np.all(df['t2'].tolist() == [543, 1, 222, 111])
    assert np.all(df['t3'].tolist() == [23,  1,  22,  11])

    sheet = ipysheet.sheet(rows=0, columns=0)

    df = ipysheet.to_dataframe(sheet)
    assert np.all(df == pd.DataFrame())

    sheet = ipysheet.sheet(rows=4, columns=1)
    ipysheet.column(0, ['2019/02/28', '2019/02/27', '2019/02/26', '2019/02/25'], type='date')

    df = ipysheet.to_dataframe(sheet)
    assert [_format_date(x) for x in df['A'].tolist()] == ['2019/02/28', '2019/02/27', '2019/02/26', '2019/02/25']
github QuantStack / ipysheet / ipysheet / test_all.py View on Github external
row.value = 1
    row.value = [0, 1, 2, 4]
    assert row.value == [0, 1, 2, 4]

    ipysheet.column(0, [0, 1, 2])
    ipysheet.column(0, [0, 1])
    ipysheet.column(0, [0, 1], row_end=1)
    ipysheet.column(0, [0, 1], row_start=1)
    with pytest.raises(ValueError):
        ipysheet.column(0, [0, 1, 2, 3])
    with pytest.raises(ValueError):
        ipysheet.column(0, [0, 1], row_end=0)
    with pytest.raises(ValueError):
        ipysheet.column(0, [0, 1, 2, 4], row_start=1)

    col = ipysheet.column(0, [0, 1, 2])
    with pytest.raises(ValueError):
        col.value = [0, 1]
    with pytest.raises(ValueError):
        col.value = 1
    col.value = [0, 1, 3]
    assert col.value == [0, 1, 3]
github QuantStack / ipysheet / ipysheet / test_all.py View on Github external
row = ipysheet.row(0, [0, 1, 2, 3])
    with pytest.raises(ValueError):
        row.value = [0, 1, 2]
    with pytest.raises(ValueError):
        row.value = 1
    row.value = [0, 1, 2, 4]
    assert row.value == [0, 1, 2, 4]

    ipysheet.column(0, [0, 1, 2])
    ipysheet.column(0, [0, 1])
    ipysheet.column(0, [0, 1], row_end=1)
    ipysheet.column(0, [0, 1], row_start=1)
    with pytest.raises(ValueError):
        ipysheet.column(0, [0, 1, 2, 3])
    with pytest.raises(ValueError):
        ipysheet.column(0, [0, 1], row_end=0)
    with pytest.raises(ValueError):
        ipysheet.column(0, [0, 1, 2, 4], row_start=1)

    col = ipysheet.column(0, [0, 1, 2])
    with pytest.raises(ValueError):
        col.value = [0, 1]
    with pytest.raises(ValueError):
        col.value = 1
    col.value = [0, 1, 3]
    assert col.value == [0, 1, 3]
github QuantStack / ipysheet / ipysheet / test_all.py View on Github external
def test_to_dataframe():
    sheet = ipysheet.sheet(rows=5, columns=4)
    ipysheet.cell(0, 0, value=True)
    ipysheet.row(1, value=[2, 34, 543, 23])
    ipysheet.column(3, value=[1.2, 1.3, 1.4, 1.5, 1.6])

    df = ipysheet.to_dataframe(sheet)
    assert np.all(df['A'].tolist() == [True,   2, None, None, None])
    assert np.all(df['B'].tolist() == [None,  34, None, None, None])
    assert np.all(df['C'].tolist() == [None, 543, None, None, None])
    assert np.all(df['D'].tolist() == [1.2,  1.3,  1.4,  1.5,  1.6])

    sheet = ipysheet.sheet(rows=4, columns=4, column_headers=['c0', 'c1', 'c2', 'c3'], row_headers=['r0', 'r1', 'r2', 'r3'])
    ipysheet.cell_range(
        [
            [2, 34, 543, 23],
            [1,  1,   1,  1],
            [2,  2, 222, 22],
            [2,  0, 111, 11],
        ],
        row_start=0, column_start=0,
github timkpaine / lantern / lantern / grids / grid_ipysheet.py View on Github external
if 'index' not in data.columns and drop_index:
            data = data.reset_index()
        for x in data.dtypes.iteritems():
            if 'date' in str(x[1]):
                data[x[0]] = data[x[0]].astype(str)
    elif isinstance(data, pd.Series):
        data = data.reset_index()
        for x in data.dtypes.iteritems():
            if 'date' in str(x[1]):
                data[x[0]] = data[x[0]].astype(str)
    else:
        raise NotImplementedError()

    sheet = ipysheet.sheet(rows=len(data), columns=len(data.columns), column_headers=data.columns.astype(str).tolist())
    for i, col in enumerate(data.columns):
        ipysheet.column(i, data[col].values.tolist())
    return sheet