ra2w commited on
Commit
86508a8
1 Parent(s): f8dccd1

Fixed a small bug

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -427,7 +427,7 @@ def nlu_query_use_api():
427
  'Which company trades at the highest revenue multiple?',
428
  'List all companies with growth rates greater than 40?',
429
  'What is the average gross margin for companies in this dataset?',
430
- 'What is the average trading multiple for companies in this dataset?'
431
 
432
  ]
433
 
@@ -441,16 +441,18 @@ def nlu_query_use_api():
441
  if 'error' in output:
442
  st.write(output['error'])
443
  else:
444
- df_output = pd.DataFrame.from_dict(output['cells'])
445
- if output['aggregator'] == 'COUNT':
446
- st.info(f"[COUNT] Answer: {df_output[0].count()}")
447
- elif output['aggregator'] == 'SUM':
448
- st.info(f"[SUM] Answer: {df_output[0].astype(float).sum().round(2)}")
449
- elif output['aggregator'] == 'AVERAGE':
450
- st.info(f"[AVERAGE] Answer: {df_output[0].astype(float).mean().round(2)}")
451
- else:
452
- st.info(f"Answer is {output['answer']}")
453
-
 
 
454
  with st.expander("Raw Output"):
455
  st.write(output)
456
  return
 
427
  'Which company trades at the highest revenue multiple?',
428
  'List all companies with growth rates greater than 40?',
429
  'What is the average gross margin for companies in this dataset?',
430
+ 'What is the average trading multiple?'
431
 
432
  ]
433
 
 
441
  if 'error' in output:
442
  st.write(output['error'])
443
  else:
444
+ try:
445
+ df_output = pd.DataFrame.from_dict(output['cells'])
446
+ if output['aggregator'] == 'COUNT':
447
+ st.info(f"[COUNT] Answer: {df_output[0].count()}")
448
+ elif output['aggregator'] == 'SUM':
449
+ st.info(f"[SUM] Answer: {df_output[0].astype(float).sum().round(2)}")
450
+ elif output['aggregator'] == 'AVERAGE':
451
+ st.info(f"[AVERAGE] Answer: {df_output[0].astype(float).mean().round(2)}")
452
+ else:
453
+ st.info(f"Answer is {output['answer']}")
454
+ except ValueError:
455
+ st.write(output)
456
  with st.expander("Raw Output"):
457
  st.write(output)
458
  return