Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
Showing results for 
Search instead for 
Did you mean: 


New Contributor

I am having an issue with getting a display upon interaction with the ipywidgets dropdown menu. Once I've selected an option from the dropdown, nothing happens. I am inclined to believe it has to do with how I've structure my on_select function and not the .observe function for the dropdown. Any suggestions?


import pyspark.sql.functions as F
from pyspark.sql import SparkSession
import ipywidgets as widgets
from IPython.display import HTML, display

# Create the SparkSession object
appName = "hive_pyspark"
master = "local"
spark = SparkSession.builder.appName(appName).enableHiveSupport().getOrCreate()

# Read in the data dictionary table 
df = spark.table("data_dictionary")

# Define a function for handling table name selections
def on_select(name, value):
    print(f"Selected Value: {value}")
    # Clear the previously displayed HTML table
    display(HTML("<div id='table-data'></div>"))
    # Filter down to the selected table
    selected_table = df.filter(F.col("table_name") == value)

    # Display the table data in an HTML table format

# Define and display a dropdown menu for selecting a table name
table_names ="table_name")).distinct().rdd.flatMap(lambda x: x).collect()
table_dropdown = widgets.Dropdown(
    description='Select Table Name:'

table_dropdown.observe(on_select, names='value')

Community Manager
Community Manager

Hi @uncle_rufus

  • Ensure that the .observe function for the dropdown is correctly set up. Verify that it’s calling the on_select function when the dropdown value changes.
  • Make sure there are no typos or syntax errors in your .observe statement.
  • Check if the selected_table DataFrame contains the expected data. Print its contents to the console for debugging purposes.
  • Confirm that the toPandas().to_html(index=False) conversion is working as expected. You can also try displaying the raw DataFrame without converting it to HTML to see if any data is retrieved.

If you encounter any specific error messages or unexpected behavior, feel free to share them, and we can continue troubleshooting! 🛠🔍

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!