pavanmutha commited on
Commit
a6cb357
·
verified ·
1 Parent(s): 86ccde9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -14
app.py CHANGED
@@ -53,20 +53,32 @@ agent = CodeAgent(
53
  additional_authorized_imports=["numpy", "pandas", "matplotlib.pyplot", "seaborn"]
54
  )
55
 
56
- analysis_result = agent.run(
57
- """
58
- You are an expert data analyst. Perform comprehensive analysis including:
59
- 1. Basic statistics and data quality checks.
60
- 2. Three insightful analytical questions about relationships in the data.
61
- 3. Visualization of key patterns and correlations.
62
- 4. Actionable real-world insights derived from findings.
63
- Generate publication-quality visualizations and save them to './figures/'.
64
- """,
65
- additional_args={
66
- "additional_notes": additional_notes, # Pass additional notes
67
- "source_file": file.name # Use the uploaded file's path
68
- }
69
- )
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  # Optionally, you can inspect the results
72
  print(analysis_result)
 
53
  additional_authorized_imports=["numpy", "pandas", "matplotlib.pyplot", "seaborn"]
54
  )
55
 
56
+ # Modify `run_agent` to directly use the cleaned `df_global`
57
+ def run_agent(_):
58
+ if df_global is None or df_global.empty:
59
+ return "No data available for analysis."
60
+
61
+ # Use the cleaned data (df_global) for analysis
62
+ analysis_result = agent.run(
63
+ """
64
+ You are an expert data analyst. Perform comprehensive analysis including:
65
+ 1. Basic statistics and data quality checks.
66
+ 2. Three insightful analytical questions about relationships in the data.
67
+ 3. Visualization of key patterns and correlations.
68
+ 4. Actionable real-world insights derived from findings.
69
+ Generate publication-quality visualizations and save them to './figures/'.
70
+ """,
71
+ additional_args={
72
+ "additional_notes": additional_notes, # Pass additional notes
73
+ "source_file": "uploaded_file.csv" # Use the appropriate file name or path if needed
74
+ }
75
+ )
76
+ return analysis_result
77
+
78
+ # Update the Gradio button to pass the cleaned data (df_global)
79
+ agent_btn.click(fn=run_agent, inputs=None, outputs=insights_output)
80
+
81
+
82
 
83
  # Optionally, you can inspect the results
84
  print(analysis_result)