In [ ]:
# 1 (Array of Integers parameter)
from beakerx import *
TableDisplay({"a":100, "b":200, "c":300})
In [ ]:
%%groovy
// expected result of cell 1
Image("../../resources/img/python/tableAPI/cell1_case1.png")
In [ ]:
# 2 (2D Array of Integers parameter)
TableDisplay([{"a":1}, {"a":10, "b":20}])
In [ ]:
%%groovy
// expected result of cell 2
Image("../../resources/img/python/tableAPI/cell2_case1.png")
In [ ]:
# 3 (Array of Decimals parameter)
TableDisplay({"a":1/10, "b":1/20, "c":0.33})
In [ ]:
%%groovy
// expected result of cell 3
Image("../../resources/img/python/tableAPI/cell3_case1.png")
In [ ]:
# 4 (2D Array of Decimals parameter)
TableDisplay([{"a":1/10}, {"a":1/100, "b":3.12345}])
In [ ]:
%%groovy
// expected result of cell 4
Image("../../resources/img/python/tableAPI/cell4_case1.png")
In [ ]:
# 5 (Array of Strings parameter)
TableDisplay({"a":'string aaa', "b":'string bbb', "c":'string ccc'})
In [ ]:
%%groovy
// expected result of cell 5
Image("../../resources/img/python/tableAPI/cell5_case1.png")
In [ ]:
# 6 (2D Array of Strings parameter)
TableDisplay([{"a":'a'}, {"a":'1a', "b":'2b'}])
In [ ]:
%%groovy
// expected result of cell 6
Image("../../resources/img/python/tableAPI/cell6_case1.png")
In [ ]:
# 7 (Array of Integer Arrays parameter)
TableDisplay({"a":[1, 2, 3], "b":[10, 20, 30], "c":[100, 200, 300]})
In [ ]:
%%groovy
// expected result of cell 7
Image("../../resources/img/python/tableAPI/cell7_case1.png")
In [ ]:
# 8 (2D Array of Integer Arrays parameter)
TableDisplay([
{"a":[1, 2, 3]},
{"a":[10, 20, 30], "b":[100, 200, 300]}])
In [ ]:
%%groovy
// expected result of cell 8
Image("../../resources/img/python/tableAPI/cell8_case1.png")
In [ ]:
# 9 (2D Array of Integer,Decimal,String,Array Arrays parameter)
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])
In [ ]:
%%groovy
// expected result of cell 9
Image("../../resources/img/python/tableAPI/cell9_case1.png")
In [ ]:
# 10 ([Integer,Decimal,String,Array] parameter)
TableDisplay({"a":100, "b":1/20, "c":'c c c', "d":[100, 200, 300]})
In [ ]:
%%groovy
// expected result of cell 10
Image("../../resources/img/python/tableAPI/cell10_case1.png")
In [ ]:
# 11 (2D Arrays of [Integer,Decimal,String,Array] parameter)
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])
In [ ]:
%%groovy
// expected result of cell 11
Image("../../resources/img/python/tableAPI/cell11_case1.png")
In [ ]:
# 12 (numbers as name of Array keys (Array parameter))
TableDisplay({10:20, 1/10:1/20, 'c':'c c c', '[100, 200]':[100, 200, 300]})
In [ ]:
%%groovy
// expected result of cell 12
Image("../../resources/img/python/tableAPI/cell12_case1.png")
In [ ]:
# 13 (numbers as name of Array keys (2D Array parameter)
row1 = {40:40, 1/40:1/40, 'c':'c'}
row2 = {40:20, 1/40:1/20, 'c':'c c c', '[100, 200]':[100, 200, 300]}
TableDisplay([row1, row2])
In [ ]:
%%groovy
// expected result of cell 13
Image("../../resources/img/python/tableAPI/cell13_case1.png")
In [ ]:
# 14
import pandas as pd
from beakerx import *
df = pd.DataFrame({"runway": ["24", "36L"]})
TableDisplay(df)
In [ ]:
%%groovy
// expected result of cell 14
Image("../../resources/img/python/tableAPI/cell14_case1.png")
In [ ]:
from beakerx import *
import pandas as pd
import numpy as np
pd.DataFrame(data=np.zeros((5,5)), index=pd.Int64Index([0, 1, 2, 3, 4], dtype='int64'))
In [ ]:
# 15
pd.read_csv('../../resources/data/pd_index.csv', index_col=0)
In [ ]:
%%groovy
// expected result of cell 15
Image("../../resources/img/python/tableAPI/cell15_case1.png")
In [ ]:
# 16
pd.read_csv('../../../doc/resources/data/interest-rates.csv')
In [ ]:
%%groovy
// expected result of cell 16
Image("../../resources/img/python/tableAPI/cell16_case1.png")
In [ ]:
# 17
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
In [ ]:
%%groovy
// expected result of cell 17
Image("../../resources/img/python/tableAPI/cell17_case1.png")
In [ ]:
# 18
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
In [ ]:
%%groovy
// expected result of cell 18
Image("../../resources/img/python/tableAPI/cell18_case1.png")
In [ ]:
# 19
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
In [ ]:
%%groovy
// expected result of cell 19
Image("../../resources/img/python/tableAPI/cell19_case1.png")
In [ ]:
# 20
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
In [ ]:
%%groovy
// expected result of cell 20
Image("../../resources/img/python/tableAPI/cell20_case1.png")
In [ ]:
# 21
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
In [ ]:
%%groovy
// expected result of cell 21
Image("../../resources/img/python/tableAPI/cell21_case1.png")
In [ ]: