Jawad commited on
Commit
2715942
·
1 Parent(s): 010fa37
Files changed (1) hide show
  1. score_app.py +8 -3
score_app.py CHANGED
@@ -6,7 +6,7 @@ from data import headers
6
 
7
  st.title("Production scores")
8
  st.sidebar.title("Parameters")
9
- source_type_value = st.sidebar.selectbox('Authority country', ['cftc', 'doj', 'cfbp'])
10
 
11
  created_at = '2021-01-01'
12
 
@@ -35,7 +35,7 @@ def load_data(source_type):
35
 
36
  df_list = load_data(source_type_value)
37
 
38
- # filter to keep processing
39
  processed_decisions = {}
40
  for decision_id, decision in df_list:
41
  _df = decision[(decision.status == 'P') & (decision.history_user == 45)]
@@ -49,6 +49,7 @@ for decision_id, decision in df_list:
49
  if _df.shape[0] > 0:
50
  validated_decisions[decision_id] = _df
51
 
 
52
  scope = list(set(processed_decisions.keys()) & set(validated_decisions.keys()))
53
  st.metric(label="Number of elements", value=len(scope))
54
 
@@ -59,11 +60,15 @@ compare_list = st.sidebar.multiselect('Fields to evaluate',
59
  'currency',
60
  'justice_type',
61
  'decision_date',
62
- 'country_of_violation'], ['monetary_sanction', 'decision_date'])
 
 
63
  result = {}
64
  details = {}
65
  for decision_id in scope:
 
66
  p = processed_decisions[decision_id].iloc[-1].to_dict()
 
67
  v = validated_decisions[decision_id].iloc[-1].to_dict()
68
  details[decision_id] = {col: (p[col], v[col]) for col in compare_list}
69
  result[decision_id] = {col: p[col] == v[col] for col in compare_list}
 
6
 
7
  st.title("Production scores")
8
  st.sidebar.title("Parameters")
9
+ source_type_value = st.sidebar.selectbox('Authority country', ['cftc', 'doj', 'cfbp', 'sec'])
10
 
11
  created_at = '2021-01-01'
12
 
 
35
 
36
  df_list = load_data(source_type_value)
37
 
38
+ # filter to keep processing -- 45 is the airflow user id
39
  processed_decisions = {}
40
  for decision_id, decision in df_list:
41
  _df = decision[(decision.status == 'P') & (decision.history_user == 45)]
 
49
  if _df.shape[0] > 0:
50
  validated_decisions[decision_id] = _df
51
 
52
+ # Intersection of the precessed and validated decisions
53
  scope = list(set(processed_decisions.keys()) & set(validated_decisions.keys()))
54
  st.metric(label="Number of elements", value=len(scope))
55
 
 
60
  'currency',
61
  'justice_type',
62
  'decision_date',
63
+ 'country_of_violation'],
64
+ ['monetary_sanction', 'decision_date'])
65
+
66
  result = {}
67
  details = {}
68
  for decision_id in scope:
69
+ # last processed version
70
  p = processed_decisions[decision_id].iloc[-1].to_dict()
71
+ # last validated version
72
  v = validated_decisions[decision_id].iloc[-1].to_dict()
73
  details[decision_id] = {col: (p[col], v[col]) for col in compare_list}
74
  result[decision_id] = {col: p[col] == v[col] for col in compare_list}