Visualize pandas dataframe in gradio
- User
Visualize pandas dataframe in gradio
Assistant
Here is Python code to visualize a pandas dataframe in gradio:
pythonimport pandas as pd import gradio as gr df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]}) def display_df(df): return df iface = gr.Interface(fn=display_df, inputs="dataframe", outputs="dataframe") iface.launch(share=True)This creates a simple gradio interface that takes a dataframe as input, and outputs/displays the dataframe.
The key steps are:
- Create a pandas dataframe
- Define a function that simply returns the df
- Create a gradio Interface, with "dataframe" as both the input and output types
- Launch the interface with share=True to create a public link
When launched, this will create an interactive UI where you can upload a dataframe and see it rendered automatically. Gradio handles displaying the dataframe nicely formatted in the interface.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.