from beakerx import *
TableDisplay({"a":100, "b":200, "c":300})
TableDisplay([{"a":1}, {"a":10, "b":20}])
TableDisplay({"a":1/10, "b":1/20, "c":0.33})
TableDisplay([{"a":1/10}, {"a":1/100, "b":3.12345}])
TableDisplay({"a":'a a a', "b":'b b b', "c":'c c c'})
TableDisplay([{"a":'a'}, {"a":'1a', "b":'2b'}])
TableDisplay({"a":[1, 2, 3], "b":[10, 20, 30], "c":[100, 200, 300]})
TableDisplay([
{"a":[1, 2, 3]},
{"a":[10, 20, 30], "b":[100, 200, 300]}])
row1 = {"a":100, "b":200, "c":300}
row2 = {"a":1/10, "b":1/20, "c":0.33}
row3 = {"a":'a a a', "b":'b b b', "c":'c c c'}
row4 = {"a":[1, 2, 3], "b":[10, 20, 30], "c":[100, 200, 300]}
TableDisplay([row1, row2, row3, row4])
TableDisplay({"a":100, "b":1/20, "c":'c c c', "d":[100, 200, 300]})
row1 = {"a":10, "b":1/10, "c":'c', "d":[100, 200]}
row2 = {"a":100, "b":1/20, "c":'c c c', "d":[100, 200, 300]}
TableDisplay([row1, row2])
TableDisplay({10:20, 1/10:1/20, 'c':'c c c', '[100, 200]':[100, 200, 300]})
row1 = {10:10, 1/10:1/10, 'c':'c'}
row2 = {10:20, 1/10:1/20, 'c':'c c c', '[100, 200]':[100, 200, 300]}
TableDisplay([row1, row2])
In addition to APIs for creating and formatting BeakerX's interactive table widget, the Python runtime configures pandas to display tables with the interactive widget instead of static HTML.
import pandas as pd
from beakerx import *
df = pd.DataFrame({"runway": ["24", "36L"]})
TableDisplay(df)
pd.read_csv('../../../doc/resources/data/interest-rates.csv')
table2 = TableDisplay(pd.read_csv('../../../doc/resources/data/interest-rates-small.csv'))
table2.setAlignmentProviderForColumn('m3', TableDisplayAlignmentProvider.CENTER_ALIGNMENT)
table2.setRendererForColumn("y10", TableDisplayCellRenderer.getDataBarsRenderer(False))
table2.setRendererForType(ColumnType.Double, TableDisplayCellRenderer.getDataBarsRenderer(True))
table2
df3 = pd.read_csv('../../../doc/resources/data/interest-rates-small.csv')
df3['time'] = df3['time'].str.slice(0,19).astype('datetime64[ns]')
table3 = TableDisplay(df3)
table3.setStringFormatForTimes(TimeUnit.DAYS)
table3.setStringFormatForType(ColumnType.Double, TableDisplayStringFormat.getDecimalFormat(2,3))
table3.setStringFormatForColumn("m3", TableDisplayStringFormat.getDecimalFormat(0, 0))
table3
table4 = TableDisplay(pd.read_csv('../../../doc/resources/data/interest-rates-small.csv'))
#freeze a column
table4.setColumnFrozen("y1", True)
#freeze a column to the right
table4.setColumnFrozenRight("y10", True)
#hide a column
table4.setColumnVisible("y30", False)
table4
table5 = TableDisplay(pd.read_csv('../../../doc/resources/data/interest-rates-small.csv'))
#Columns in the list will be shown in the provided order. Columns not in the list will be hidden.
table5.setColumnOrder(["m3", "y1", "y10", "time", "y2"])
table5
colNames = ["m3","y30","time","y5","y7","spread"]
row1 = [7.8981, 8.2586, "1990-01-30 19:00:00.000 -0500", 8.1195, 8.1962, 0.3086]
row2 = [2.0021, 8.5037, "1990-02-27 19:00:00.000 -0500", 8.4247, 8.4758, 0.4711]
row3 = [2.0021, 3.5037, "1990-05-27 19:00:00.000 -0500", 1.4247, 4.4758, 5.4711]
table6 = TableDisplay(pd.DataFrame([row1, row2, row3], columns=colNames))
table6.addCellHighlighter(TableDisplayCellHighlighter.getHeatmapHighlighter("m3", TableDisplayCellHighlighter.FULL_ROW))
table6