Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
How to manipulate a pandas dataframe using a JavaScript callback in Bokeh?

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!