Skip to content
Advertisement

how to fix error “DataFrame object is not callable” in python and streamlit

I have a python code that display dataframe and allow the user to filter the dataframe by creating a new dataframe and allow him to update the requested record using the index number from the selectedbox.

For this reason i am using the new feature of streamlit session state where i want the system to preserve the filtered dataframe after the user change the the value of the selectbox by using the callback feature

The problem is that once the user select the value from the selectbox the system crash and display the below error:

JavaScript

code:

JavaScript

based on the answer of Joran Beasley

the system return the selected value but is not showing the dataframe

after the user select the value the page refresh this what is happening:

  1. dataframe disapper
  2. selectbox is saved the selected value
  3. the update expander return all the values of all records in each column.

So for this reason i used the callback()

what i want is to :

  1. dataframe still appear.
  2. selectbox is saved the selected value
  3. the update expander return values of the selected index number in each column.

How can I achieve these 3 tasks???

enter image description here

Advertisement

Answer

try doing

on_change=lambda: update_df(df_result_search)

before you basically had

JavaScript

on_change needs a function that it can call … it cannot call the dataframe returned … in the suggested solution we simply convert it into a lambda that will be called when the select choice is changed.

(of coarse it probably passes some sort of “change_event” that you should probably use to select a column or something)

...on_change= lambda evt:do_something_with_event(evt)

on further examination I think you do not quite understand how streamlit works

this example should help you understand why you still have some issues

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement