Akshayram1 commited on
Commit
a07d7fa
·
verified ·
1 Parent(s): 02791b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -40
app.py CHANGED
@@ -3,20 +3,36 @@ import pandas as pd
3
  import matplotlib.pyplot as plt
4
 
5
  def process_data(df):
6
- # Convert dates and filter relevant period
7
- df['Start Date'] = pd.to_datetime(df['Date'].str.split(' to ').str[0], format='%d/%b/%y')
8
- df['End Date'] = pd.to_datetime(df['Date'].str.split(' to ').str[1], format='%d/%b/%y')
9
 
10
- # Categorize into weeks
 
11
  df['Week'] = df['Start Date'].apply(lambda x: 1 if x <= pd.Timestamp('2025-01-05') else 2)
12
 
13
- return df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  def create_utilization_chart(week_data, week_number):
16
  fig, ax = plt.subplots()
17
  wedges, texts, autotexts = ax.pie(
18
- week_data[['Billable', 'Non-Billable', 'Leaves']].values[0],
19
- labels=['Billable', 'Non-Billable', 'Leaves'],
20
  autopct='%1.1f%%',
21
  colors=['#4CAF50', '#FFC107', '#9E9E9E']
22
  )
@@ -24,18 +40,6 @@ def create_utilization_chart(week_data, week_number):
24
  ax.set_title(f'Week {week_number} Utilization', pad=20)
25
  return fig
26
 
27
- def create_non_billable_breakdown(df):
28
- non_billable = df[df['Project Category'] == 'Non-Billable']
29
- breakdown = non_billable.groupby('Epic')['Logged'].sum().reset_index()
30
- breakdown = breakdown[breakdown['Epic'] != 'No Epic']
31
-
32
- fig, ax = plt.subplots()
33
- breakdown.plot(kind='bar', x='Epic', y='Logged', ax=ax, legend=False)
34
- ax.set_title('Non-Billable Time Breakdown')
35
- ax.set_ylabel('Hours')
36
- plt.xticks(rotation=45)
37
- return fig
38
-
39
  def main():
40
  st.title('QA Team Utilization Dashboard')
41
 
@@ -43,37 +47,19 @@ def main():
43
 
44
  if uploaded_file:
45
  df = pd.read_excel(uploaded_file, sheet_name='Report')
46
- df = process_data(df)
47
 
48
  # Page 4 Visualization
49
  st.header("Bi-Weekly Utilization Report")
50
  col1, col2 = st.columns(2)
51
 
52
  with col1:
53
- week1 = df[df['Week'] == 1]
54
  st.pyplot(create_utilization_chart(week1, 1))
55
 
56
  with col2:
57
- week2 = df[df['Week'] == 2]
58
  st.pyplot(create_utilization_chart(week2, 2))
59
-
60
- # Page 5 Visualization
61
- st.header("Non-Billable Time Breakdown")
62
- st.pyplot(create_non_billable_breakdown(df))
63
-
64
- # Page 6 Visualization
65
- st.header("Solution Accelerators Progress")
66
- accelerators = df[(df['Project Category'] == 'Non-Billable') &
67
- (df['Epic'] == 'Solution Accelerators')]
68
-
69
- st.dataframe(
70
- accelerators[['Project', 'Logged', 'Key']].rename(columns={
71
- 'Project': 'Initiative',
72
- 'Logged': 'Hours',
73
- 'Key': 'Status'
74
- }),
75
- hide_index=True
76
- )
77
 
78
  if __name__ == "__main__":
79
  main()
 
3
  import matplotlib.pyplot as plt
4
 
5
  def process_data(df):
6
+ # Clean and transform data
7
+ df = df[df['Project Category'].notna()]
 
8
 
9
+ # Create Week buckets
10
+ df['Start Date'] = pd.to_datetime(df['Date'].str.split(' to ').str[0], format='%d/%b/%y')
11
  df['Week'] = df['Start Date'].apply(lambda x: 1 if x <= pd.Timestamp('2025-01-05') else 2)
12
 
13
+ # Aggregate utilization data
14
+ utilization = df.groupby(['Week', 'Project Category'])['Logged'].sum().unstack(fill_value=0)
15
+
16
+ # Calculate percentages
17
+ total_hours = utilization.sum(axis=1)
18
+ utilization_percent = utilization.div(total_hours, axis=0) * 100
19
+
20
+ # Select relevant categories
21
+ utilization_percent = utilization_percent[['Fixed Bid Projects - Billable',
22
+ 'Non-Billable',
23
+ 'Leaves']].rename(columns={
24
+ 'Fixed Bid Projects - Billable': 'Billable',
25
+ 'Non-Billable': 'Non-Billable',
26
+ 'Leaves': 'Leaves'
27
+ })
28
+
29
+ return utilization_percent
30
 
31
  def create_utilization_chart(week_data, week_number):
32
  fig, ax = plt.subplots()
33
  wedges, texts, autotexts = ax.pie(
34
+ week_data.values,
35
+ labels=week_data.index,
36
  autopct='%1.1f%%',
37
  colors=['#4CAF50', '#FFC107', '#9E9E9E']
38
  )
 
40
  ax.set_title(f'Week {week_number} Utilization', pad=20)
41
  return fig
42
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  def main():
44
  st.title('QA Team Utilization Dashboard')
45
 
 
47
 
48
  if uploaded_file:
49
  df = pd.read_excel(uploaded_file, sheet_name='Report')
50
+ utilization_percent = process_data(df)
51
 
52
  # Page 4 Visualization
53
  st.header("Bi-Weekly Utilization Report")
54
  col1, col2 = st.columns(2)
55
 
56
  with col1:
57
+ week1 = utilization_percent.loc[1]
58
  st.pyplot(create_utilization_chart(week1, 1))
59
 
60
  with col2:
61
+ week2 = utilization_percent.loc[2]
62
  st.pyplot(create_utilization_chart(week2, 2))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
  if __name__ == "__main__":
65
  main()