With Bokeh, is it possible to manipulate a pandas dataframe from within a JavaScript callback? I don't want to have to rely on a Bokeh server.
I have a slider and a dropdown menu. The slider selects the year. The menu selects which dataframe I'll use via category (there are multiple dataframes, but they are all derived from the same parent dataframe).
The data I want to update is a dictionary that relies on pandas to select values based on the top 10 values of a specific column from within one of several dataframes, like this:
def update_plot(attr, old, new):
year = my_slider.value
category = select_category.value
match category:
case 'category1':
my_df = df1
case 'category2':
my_df = df2
# select the top 10 paid people for a specific year
new_data = { 'person_name' : my_df[my_df['YEAR'] == year].nlargest(10, 'salary').person_name }
.nlargest is a member function of a pandas dataframe. My guess is that I won't be able to call that function using JavaScript, and I need to use JavaScript so that I don't have to rely on the Bokeh server. I'm pretty clueless as to how I'd achieve the same effect using JavaScript.
Any guidance is appreciated. I think I shared all of the relevant parts of my script needed to answer this question, but I can provide more if needed.