Prerequisites

pip install ipysheet


In [38]:
from ipywidgets import FloatSlider, IntSlider, Image
import ipysheet

1. Test Rendering a Sheet


In [39]:
sheet = ipysheet.sheet(rows=3, columns=4)
cell1 = ipysheet.cell(0, 0, 'Hello')
cell2 = ipysheet.cell(2, 0, 'World')
cell_value = ipysheet.cell(2,2, 42.)
sheet

2. Test Searching a Sheet (interact with textbox in a different cell)


In [40]:
import numpy as np
import pandas as pd
from ipysheet import from_dataframe
from ipywidgets import Text, VBox, link

df = pd.DataFrame({'A': 1.,
                   'B': pd.Timestamp('20130102'),
                   'C': pd.Series(1, index=list(range(4)), dtype='float32'),
                   'D': np.array([False, True, False, False], dtype='bool'),
                   'E': pd.Categorical(["test", "train", "test", "train"]),
                   'F': 'foo'})

df.loc[[0, 2], ['B']] = np.nan


sheet2 = from_dataframe(df)

search_box = Text(description='Search:')
link((search_box, 'value'), (sheet2, 'search_token'))

In [41]:
search_box

In [42]:
sheet2

3. Test calculations (slider update cell value via python code)


In [51]:
from ipywidgets import FloatSlider, IntSlider, Image, IntText, link
import ipysheet

slider = IntSlider(description="Continuous", continuous_update=True)
textbox = IntText(description="Continuous", continuous_update=True)

link((slider, 'value'), (textbox, 'value'))

In [52]:
slider
  • Typing value into textbox will move slider
  • The value in cell will also get updated

In [53]:
textbox

In [57]:
sheet = ipysheet.sheet()

cell1 = ipysheet.cell(0, 0, slider, style={'min-width': '150px'})
cell3 = ipysheet.cell(2, 2, 50.)
cell_sum = ipysheet.cell(3, 2, 50.)

@ipysheet.calculation(inputs=[(cell1, 'value'), cell3], output=cell_sum)
def calculate(a, b):
    return a + b

sheet

In [ ]: