Manasa1 commited on
Commit
9302e83
·
verified ·
1 Parent(s): 5c75aef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -15
app.py CHANGED
@@ -42,28 +42,38 @@ def fetch_esg_data(company_name):
42
  # Return an empty DataFrame and None if no data is available
43
  return pd.DataFrame(), None
44
 
45
- # Gradio interface with a dropdown for company selection, line plot visualization, and CSV download
46
  def app_interface():
47
  with gr.Blocks() as app:
48
- # Dropdown to select company name
49
- company = gr.Dropdown(label="Select Company", choices=list(company_dict.keys()), value="Apple")
 
50
 
51
- # Button to fetch and plot ESG data
52
- plot_button = gr.Button("Generate ESG Plot")
53
 
54
- # LinePlot component for displaying the ESG data
55
- plot_output = gr.LinePlot(label="ESG Scores Plot", x="ESG Category", y="Score", overlay_point=True)
56
 
57
- # Textbox to display messages
58
- message = gr.Textbox(label="Message", interactive=False)
59
 
60
- # File output for CSV download
61
- csv_output = gr.File(label="Download CSV")
62
 
63
- # Define the action when the "Generate ESG Plot" button is clicked
64
- plot_button.click(fn=fetch_esg_data,
65
- inputs=company,
66
- outputs=[plot_output, csv_output])
 
 
 
 
 
 
 
 
 
67
 
68
  return app
69
 
 
42
  # Return an empty DataFrame and None if no data is available
43
  return pd.DataFrame(), None
44
 
45
+ # Gradio interface with multiple tabs
46
  def app_interface():
47
  with gr.Blocks() as app:
48
+ with gr.Tab("ESG Data Analysis"):
49
+ # Dropdown to select company name
50
+ company = gr.Dropdown(label="Select Company", choices=list(company_dict.keys()), value="Apple")
51
 
52
+ # Button to fetch and plot ESG data
53
+ plot_button = gr.Button("Generate ESG Plot")
54
 
55
+ # LinePlot component for displaying the ESG data
56
+ plot_output = gr.LinePlot(label="ESG Scores Plot", x="ESG Category", y="Score", overlay_point=True)
57
 
58
+ # Textbox to display messages
59
+ message = gr.Textbox(label="Message", interactive=False)
60
 
61
+ # File output for CSV download
62
+ csv_output = gr.File(label="Download CSV")
63
 
64
+ # Define the action when the "Generate ESG Plot" button is clicked
65
+ plot_button.click(fn=fetch_esg_data,
66
+ inputs=company,
67
+ outputs=[plot_output, csv_output])
68
+
69
+ with gr.Tab("Tab 2"):
70
+ gr.Markdown("This is Tab 2. You can add more content here.")
71
+
72
+ with gr.Tab("Tab 3"):
73
+ gr.Markdown("This is Tab 3. Add your custom functionality here.")
74
+
75
+ with gr.Tab("Tab 4"):
76
+ gr.Markdown("This is Tab 4. Add more features or visualization here.")
77
 
78
  return app
79