rameshmoorthy commited on
Commit
d250988
1 Parent(s): 1e376b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -1
app.py CHANGED
@@ -8,6 +8,7 @@ import sweetviz as sv
8
  from autoviz.AutoViz_Class import AutoViz_Class
9
  from traceml.summary.df import DataFrameSummary
10
  import os
 
11
 
12
  def variable_table(df):
13
  """
@@ -71,6 +72,7 @@ def variable_table(df):
71
 
72
  def generate_report(file, type):
73
  df = pd.read_csv(file) if file.name.endswith(".csv") else pd.read_excel(file)
 
74
 
75
  pandas_html_report =ydata_profiling.ProfileReport(df).to_html()
76
  temp_file1 = NamedTemporaryFile(delete=False, suffix=".html")
@@ -92,7 +94,7 @@ def generate_report(file, type):
92
 
93
  df = convert_mixed_to_str(df.copy())
94
  df.columns = df.columns.str.upper()
95
-
96
  sweetviz_report = sv.analyze(df)
97
  #sweetviz_report=sweetviz_report.show_html()
98
  #print(type(sweetviz_report))
@@ -179,6 +181,10 @@ def generate_report(file, type):
179
 
180
 
181
  return [temp_file1.name ,temp_file3.name ,variable_table(df),dfviz,sd1]+reports+imgs
 
 
 
 
182
 
183
  def handle_click(file, sheet_name):
184
  print('Handle click')
@@ -226,7 +232,20 @@ with gr.Blocks() as cluster:
226
  gr.HTML(value="""<h2 style="color: #BA4A00; text-shadow: 1px 1px 2px #ddd;"COLUMNS STATS AND ANALYSIS</h2>""")
227
  #gr.Markdown("#Columns Analysis")
228
  dataframe2=gr.Dataframe()
 
 
 
 
 
 
 
 
 
 
 
229
 
 
 
230
  #Autoviz insights graphs
231
 
232
  gr.HTML(value="""<h3 style="color: #1999FF; text-shadow: 1px 1px 2px #ddd;">Insight Visualisations</h3>""")
 
8
  from autoviz.AutoViz_Class import AutoViz_Class
9
  from traceml.summary.df import DataFrameSummary
10
  import os
11
+ df1=gr.State()
12
 
13
  def variable_table(df):
14
  """
 
72
 
73
  def generate_report(file, type):
74
  df = pd.read_csv(file) if file.name.endswith(".csv") else pd.read_excel(file)
75
+
76
 
77
  pandas_html_report =ydata_profiling.ProfileReport(df).to_html()
78
  temp_file1 = NamedTemporaryFile(delete=False, suffix=".html")
 
94
 
95
  df = convert_mixed_to_str(df.copy())
96
  df.columns = df.columns.str.upper()
97
+ df1.value=df
98
  sweetviz_report = sv.analyze(df)
99
  #sweetviz_report=sweetviz_report.show_html()
100
  #print(type(sweetviz_report))
 
181
 
182
 
183
  return [temp_file1.name ,temp_file3.name ,variable_table(df),dfviz,sd1]+reports+imgs
184
+
185
+ def query_chat(query):
186
+ df=df1.value
187
+ return df.sketch.ask(query)
188
 
189
  def handle_click(file, sheet_name):
190
  print('Handle click')
 
232
  gr.HTML(value="""<h2 style="color: #BA4A00; text-shadow: 1px 1px 2px #ddd;"COLUMNS STATS AND ANALYSIS</h2>""")
233
  #gr.Markdown("#Columns Analysis")
234
  dataframe2=gr.Dataframe()
235
+
236
+ with gr.Column():
237
+ gr.HTML(value="""<h2 style="color: #BA4A00; text-shadow: 1px 1px 2px #ddd;"ASK QUESTIONS ON THE COLUMNS </h2>""")
238
+ with gr.Row():
239
+ query=gr.Textbox(label="Enter any question on data columns",
240
+ info="Natural language query",
241
+ lines=1,
242
+ value="What is maximum value of first column")
243
+ outlabel=gr.HighlightedText(label='Query Result ')
244
+ query_btn=gr.Button(value='Submit Query')
245
+ query_btn.click(query_chat,inputs=query,outputs=outlabel)
246
 
247
+
248
+
249
  #Autoviz insights graphs
250
 
251
  gr.HTML(value="""<h3 style="color: #1999FF; text-shadow: 1px 1px 2px #ddd;">Insight Visualisations</h3>""")