@@ -12,8 +12,8 @@ def prepare_dataframe(entries, workflow_impact_map=None, task_complexity_map=Non
1212
1313 Args:
1414 entries: List of entry dictionaries
15- workflow_impact_map: Optional mapping for workflow impact reverse lookup
16- task_complexity_map: Optional mapping for task complexity reverse lookup
15+ workflow_impact_map: Optional mapping for workflow impact reverse lookup (kept for backwards compatibility)
16+ task_complexity_map: Optional mapping for task complexity reverse lookup (kept for backwards compatibility)
1717
1818 Returns:
1919 Cleaned pandas DataFrame
@@ -22,14 +22,13 @@ def prepare_dataframe(entries, workflow_impact_map=None, task_complexity_map=Non
2222 if df .empty :
2323 return df
2424
25- # Apply reverse mappings if provided
25+ # Legacy field handling for backwards compatibility with old data
2626 if workflow_impact_map and 'Workflow Impact' in df .columns :
2727 df ['Workflow Impact' ] = df ['Workflow Impact' ].map (workflow_impact_map ).fillna (df ['Workflow Impact' ])
2828 if task_complexity_map and 'Task Complexity' in df .columns :
2929 df ['Task Complexity' ] = df ['Task Complexity' ].map (task_complexity_map ).fillna (df ['Task Complexity' ])
3030
31- # Calculate time saved and ensure timestamp is datetime
32- df ["Time Saved" ] = df ["Time Without AI" ] - df ["Duration" ]
31+ # Ensure timestamp is datetime
3332 df ["Timestamp" ] = pd .to_datetime (df ["Timestamp" ], errors = "coerce" )
3433
3534 return df
@@ -68,9 +67,7 @@ def calculate_basic_stats(df):
6867
6968 stats = {
7069 'total_entries' : len (df ),
71- 'avg_time_saved' : df ["Time Saved" ].mean () if "Time Saved" in df .columns else 0 ,
7270 'avg_duration' : df ["Duration" ].mean () if "Duration" in df .columns else 0 ,
73- 'avg_satisfaction' : df ["Satisfaction" ].mean () if "Satisfaction" in df .columns else 0 ,
7471 }
7572
7673 # Tool-specific stats
@@ -125,62 +122,29 @@ def calculate_tool_effectiveness(df):
125122 if df .empty or "AI Tool" not in df .columns :
126123 return pd .DataFrame ()
127124
128- agg_dict = {}
129- if "Time Saved" in df .columns :
130- agg_dict ["Time Saved" ] = "mean"
131- if "Satisfaction" in df .columns :
132- agg_dict ["Satisfaction" ] = "mean"
133- if "Workflow Impact" in df .columns :
134- agg_dict ["Workflow Impact" ] = lambda x : x .value_counts ().index [0 ] if not x .empty else None
135-
136- if not agg_dict :
137- return pd .DataFrame ()
125+ agg_dict = {
126+ "Duration" : ["mean" , "count" ] # Average duration and task count
127+ }
138128
139129 tool_stats = df .groupby ("AI Tool" ).agg (agg_dict ).reset_index ()
140130
141- # Rename columns for clarity
142- rename_dict = {
143- "Time Saved" : "Avg Time Saved" ,
144- "Satisfaction" : "Avg Satisfaction" ,
145- "Workflow Impact" : "Most Common Workflow Impact"
146- }
147- tool_stats .rename (columns = rename_dict , inplace = True )
131+ # Flatten column names
132+ tool_stats .columns = ["AI Tool" , "Avg Duration" , "# Tasks" ]
148133
149134 return tool_stats
150135
151136
152137def calculate_complexity_analysis (df ):
153138 """
154- Calculate task complexity analysis.
139+ Calculate task complexity analysis (legacy function - returns empty for backwards compatibility) .
155140
156141 Args:
157142 df: pandas DataFrame with usage data
158143
159144 Returns:
160- DataFrame with complexity analysis
145+ Empty DataFrame ( complexity analysis no longer supported)
161146 """
162- if df .empty or "Task Complexity" not in df .columns :
163- return pd .DataFrame ()
164-
165- agg_dict = {}
166- if "Time Saved" in df .columns :
167- agg_dict ["Time Saved" ] = "mean"
168- if "Satisfaction" in df .columns :
169- agg_dict ["Satisfaction" ] = "mean"
170-
171- if not agg_dict :
172- return pd .DataFrame ()
173-
174- complexity_stats = df .groupby ("Task Complexity" ).agg (agg_dict ).reset_index ()
175-
176- # Rename columns for clarity
177- rename_dict = {
178- "Time Saved" : "Avg Time Saved" ,
179- "Satisfaction" : "Avg Satisfaction"
180- }
181- complexity_stats .rename (columns = rename_dict , inplace = True )
182-
183- return complexity_stats
147+ return pd .DataFrame ()
184148
185149
186150def calculate_manager_insights (df ):
@@ -196,21 +160,14 @@ def calculate_manager_insights(df):
196160 if df .empty or "Manager" not in df .columns :
197161 return pd .DataFrame ()
198162
199- agg_dict = {"Duration" : "count" } # Count of tasks
200- if "Time Saved" in df .columns :
201- agg_dict ["Time Saved" ] = "mean"
202- if "Satisfaction" in df .columns :
203- agg_dict ["Satisfaction" ] = "mean"
163+ agg_dict = {
164+ "Duration" : ["count" , "mean" ] # Count of tasks and average duration
165+ }
204166
205167 manager_stats = df .groupby ("Manager" ).agg (agg_dict ).reset_index ()
206168
207- # Rename columns for clarity
208- rename_dict = {
209- "Time Saved" : "Avg Time Saved" ,
210- "Satisfaction" : "Avg Satisfaction" ,
211- "Duration" : "# Tasks"
212- }
213- manager_stats .rename (columns = rename_dict , inplace = True )
169+ # Flatten column names
170+ manager_stats .columns = ["Manager" , "# Tasks" , "Avg Duration" ]
214171
215172 return manager_stats
216173
@@ -228,23 +185,13 @@ def calculate_purpose_insights(df):
228185 if df .empty or "Purpose" not in df .columns :
229186 return pd .DataFrame ()
230187
231- agg_dict = {"Duration" : "count" } # Count of tasks
232- if "Time Saved" in df .columns :
233- agg_dict ["Time Saved" ] = "mean"
234- if "Satisfaction" in df .columns :
235- agg_dict ["Satisfaction" ] = "mean"
236- if "Workflow Impact" in df .columns :
237- agg_dict ["Workflow Impact" ] = lambda x : x .value_counts ().index [0 ] if not x .empty else None
188+ agg_dict = {
189+ "Duration" : ["count" , "mean" ] # Count of tasks and average duration
190+ }
238191
239192 purpose_stats = df .groupby ("Purpose" ).agg (agg_dict ).reset_index ()
240193
241- # Rename columns for clarity
242- rename_dict = {
243- "Time Saved" : "Avg Time Saved" ,
244- "Satisfaction" : "Avg Satisfaction" ,
245- "Workflow Impact" : "Most Common Workflow Impact" ,
246- "Duration" : "# Tasks"
247- }
248- purpose_stats .rename (columns = rename_dict , inplace = True )
194+ # Flatten column names
195+ purpose_stats .columns = ["Purpose" , "# Tasks" , "Avg Duration" ]
249196
250197 return purpose_stats
0 commit comments