Take this sample code as a reference, to be executed on a Databricks notebook:
import ipywidgets as widgets
# Create button widget. Clicking this button loads a sampled dataframe from UC table.
button = widgets.Button(description="Load dataframe sample")
# Output widget to display the loaded dataframe
output = widgets.Output()
def load_sample_df(table_name):
return pd.DataFrame([[1,2,3],[4,5,6]])
def on_button_clicked(_):
with output:
output.clear_output()
df = load_sample_df('<catalog>.<schema>.<table>')
display(df)
# Register the button's callback function to query UC and display results to the output widget
button.on_click(on_button_clicked)
display(button, output)
The output has an unwanted list of commas “,,,,,”, I think it has to do with the fact that the “display(df)” command gets logged as a json or dict in the Output() method, but how can I get rid of it? I need to display the df as an output and not print it, I need to keep the display(df) but remove the commas, I can’t find a way though, please help me!