Vineedhar commited on
Commit
6d02524
·
verified ·
1 Parent(s): 4a92960

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -28
app.py CHANGED
@@ -142,14 +142,14 @@ if uploaded_file is not None:
142
  for item in json_output:
143
  for label, phrases in item.items():
144
  for phrase in phrases:
145
- data.append({'Label': label, 'Dimensions': phrase})
146
 
147
  df4 = pd.DataFrame(data)
148
 
149
  #Step 9: Converting Streangths and Weaknesses with scores into json
150
 
151
  # Filter dataframes based on 'Label' value
152
- boss, direct, colleague, other_colleague = [df4[df4['Label'] == label].copy() for label in ['Boss', 'Direct', 'Colleagues', 'Colleague (o']]
153
 
154
  # Create mapping dictionaries from df3
155
  mappings = {
@@ -170,32 +170,24 @@ if uploaded_file is not None:
170
  colleague = colleague.sort_values(by = 'Colleague_score', ascending = False).reset_index(drop = True)
171
  other_colleague = other_colleague.sort_values(by = 'Other_colleague_score', ascending = False).reset_index(drop = True)
172
 
173
-
174
- boss_json = boss.iloc[:,1:].head(3).to_dict(orient='records')
175
- prompt = f"You are a corporate trainer who guides me how to behave in corporate settings. You will analyze the top 3 strengths and scores{boss_json} rated by my boss out of 6. You will generate a nudge for each dimension to improveupon these strengths."
176
-
 
 
 
 
 
 
 
 
 
 
 
177
  st.write("## Output:")
178
- st.write("### 1. Extracted data: Dimensions Assessment of the leader by: Boss, Colleagues, Colleagues (other b.), Direct reports, Customers and All Raters")
179
- st.write("### 2. Derived data: Self score")
180
- st.write("#### Dataset Table")
181
  st.dataframe(df_combined)
182
 
183
- st.write("### 3.1 Extracted list of Strengths rated by Boss")
184
- st.write(boss.head(3))
185
- st.write("### 3.2 Extracted list of Weaknesses rated by Boss")
186
-
187
- st.write(boss.tail(3))
188
- st.write("### 4.1 Extracted list of Strengths rated by Direct Reports")
189
- st.write(direct.head(3))
190
- st.write("### 4.2 Extracted list of Weaknesses rated by Direct Reports")
191
- st.write(direct.tail(3))
192
-
193
- st.write("### 5.1 Extracted list of Strengths rated by Colleague")
194
- st.write(colleague.head(3))
195
- st.write("### 5.2 Extracted list of Weaknesses rated by Colleague")
196
- st.write(colleague.tail(3))
197
-
198
- st.write("### 6.1 Extracted list of Strengths rated by Other Colleague")
199
- st.write(other_colleague.head(3))
200
- st.write("### 6.2 Extracted list of Weaknesses rated by Other Colleague")
201
- st.write(other_colleague.tail(3))
 
142
  for item in json_output:
143
  for label, phrases in item.items():
144
  for phrase in phrases:
145
+ data.append({'Rater': label, 'Dimensions': phrase})
146
 
147
  df4 = pd.DataFrame(data)
148
 
149
  #Step 9: Converting Streangths and Weaknesses with scores into json
150
 
151
  # Filter dataframes based on 'Label' value
152
+ boss, direct, colleague, other_colleague = [df4[df4['Rater'] == label].copy() for label in ['Boss', 'Direct', 'Colleagues', 'Colleague (o']]
153
 
154
  # Create mapping dictionaries from df3
155
  mappings = {
 
170
  colleague = colleague.sort_values(by = 'Colleague_score', ascending = False).reset_index(drop = True)
171
  other_colleague = other_colleague.sort_values(by = 'Other_colleague_score', ascending = False).reset_index(drop = True)
172
 
173
+ def assign_strength_weakness(df):
174
+ df['Strength/Weakness'] = np.nan
175
+ df.loc[df.index.isin([0, 1, 2]) & df['Score'].notna(), 'Strength/Weakness'] = 'S'
176
+ df.loc[df.index.isin([3, 4, 5]) & df['Score'].notna(), 'Strength/Weakness'] = 'W'
177
+ return df
178
+
179
+ # Apply the function to each DataFrame
180
+ boss = assign_strength_weakness(boss)
181
+ direct = assign_strength_weakness(direct)
182
+ colleague = assign_strength_weakness(colleague)
183
+ other_colleague = assign_strength_weakness(other_colleague)
184
+
185
+ df5 = pd.concat([boss, direct, colleague, other_colleague], axis = 0)
186
+ df5 = df5.dropna()
187
+
188
  st.write("## Output:")
189
+ st.write("### 1. Extracted dataset: Dimensions, Compentency Cluster, Raters and Scores by Raters")
 
 
190
  st.dataframe(df_combined)
191
 
192
+ st.write("### 2. Extracted list of Strengths and Weaknesses rated by each Rater")
193
+ st.write(df5)