Skip to content Skip to sidebar Skip to footer

Filtering Dataframe Using Bokeh/widget/callback

Currently my data set is in the format: Date, Currency, Price which I am filtering at Currency level and then using it to generate graphs. I want to improve it so that all the filt

Solution 1:

#Creating CCyPair wise menu
menu = Select(options=['AUDUSD','USDJPY'], value='AUDUSD')
#Function for dataframe
def get_all_price_dataset(src,name):
  df = src[(src.CCYPair == name) & (src.TYPE == 'Prices')].copy()
  return df
# Function to update Plot
def update_plot(attrname, old, new):
  newccy = menu.value
  side = buysellmenu.value
  datevalue = datemenu.value
  src_data_table = 
  ColumnDataSource(get_all_dataset(Combined,newccy,side,datevalue))
  DisplayData.data.update(src_data_table.data)
  #On change in menu,function gets called.
  menu.on_change('value', update_plot)
  #Displaying Menu and Plot.
  layout = layout([menu],
                  [plot])
  curdoc().add_root(layout)

Post a Comment for "Filtering Dataframe Using Bokeh/widget/callback"