I need help with setting up the bokeh app to make an interactive data table and download the data table as a csv file based on slider inputs
I have about 60 such parameters and about 150 thousand combinations of them.
I am trying to fix up some 15 to 20 sliders and trying to play with them to see which of these combinations fall into my criteria based on some filters.I have used some filters to sort the data and have selected top 100 of them based on the filters the user would input,
currently, with this code, the table does shows up and sliders work well updating the data table
I need help saving this table when ever user wishes to based on the filter the user has set. some thing similar to saving a calculation result file
I have written the code on the latest Python 3.7 and latest Bokeh 1.2.0 and latest Pandas on Spyder IDE. I tried doing custom JS since I don’t really know to programme on JavaScript, I would rather avoid it completely.
import numpy as np
import pandas as pd from pandas import DataFrame import numpy as np from bokeh.models import HoverTool from bokeh.themes import built_in_themes from bokeh.io import curdoc from bokeh.models import Slider,DataTable, TableColumn from bokeh.plotting import figure, output_file, show, ColumnDataSource from bokeh.layouts import row, column, gridplot from bokeh.models.widgets import Tabs, Panel from bokeh.core.properties import Float, Instance, Tuple, Bool, Enum from bokeh.models import InputWidget from bokeh.models.callbacks import Callback from bokeh.models.widgets import RangeSlider df = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD')) source = ColumnDataSource(df) a_Slider= RangeSlider(start=min(df['A']), end=max(df['A']), value=(min(df['A']),max(df['A'])), step=1, title='YY in mm') B_Slider = RangeSlider(start=min(df['B']), end=max(df['B']), value=(min(df['B']),max(df['B'])), step=1, title='ZZ') def callback(attr,new,old) A_s = A_Slider.value[0] A_e = A_Slider.value[1] B_1_s= B_1_Slider.value[0] B_1_e= B_1_Slider.value[1] dff= pd.DataFrame(df[(df.A >=A_s) & (df.A <= A_e) & (df.B_1 >= B_s) & (df.B <= B_e)]) source.data = ColumnDataSource.from_df(dff) #function ends here A_Slider.on_change("value",callback) B_Slider.on_change("value",callback) columns = [TableColumn(field='No.', title='Concept No'), TableColumn(field='A', title='a'), TableColumn(field='B', title='z_1'), TableColumn(field='C', title='z_2'), TableColumn(field='D', title='u')] table=DataTable(source=source,columns = columns) Graphs = row([table]) Controls1= column([A_Slider,B_Slider]) layout= row(Controls1,Graphs)
I am expecting a some guidance on creating a button for download of the data table with user defined names in the user defined directories, so that if the user wishes the filtered data can be downloaded
on a second priority if you could guide me to write a loop for each of sliders definition and callback
I don’t want to repeat every line again and again.