Skip to content

Commit b937f8a

Browse files
#REQ_DEV
Prompt Category: Requirement Development Prompt: Suggest Python code, to do the following: - Calculate Mean Rating: - Average of (Context Awareness, Autonomy, Experience, Output Quality) - Calculate difference: - Difference = Mean Rating - Overall Rating - Determine Result status: - "Ok" (green) if -1 ≤ difference ≤ 1 - "Not ok" (red) if difference < -1 or > 1 extract_data.py User Observation: Observed that the required columns were extracted and the Mean Rating was calculated Response ID: c6053bc4-9ef2-475c-b2df-0ac54cbd104b
1 parent 9fb7418 commit b937f8a

File tree

4 files changed

+148
-12
lines changed

4 files changed

+148
-12
lines changed

.coverage

52 KB
Binary file not shown.

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
credentials.json
2-
app.log
2+
app.log
3+
.coverage

app.log

+88
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,91 @@
1212
2025-03-13 17:52:54,403 - WARNING - Column 'POD' not found in sheet
1313
2025-03-13 17:52:54,405 - INFO - Successfully filtered required columns
1414
2025-03-13 17:52:54,405 - INFO - Data retrieval successful
15+
2025-03-13 18:05:17,826 - INFO - Successfully loaded credentials
16+
2025-03-13 18:05:17,826 - INFO - Successfully created Google Sheets service
17+
2025-03-13 18:05:17,826 - ERROR - An error occurred: API Error
18+
Traceback (most recent call last):
19+
File "/Users/surya.sandeep.boda/Desktop/Marscode Zero to One 3/extract_data.py", line 44, in get_google_sheet_data
20+
result = sheet.values().get(
21+
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/unittest/mock.py", line 1093, in __call__
22+
return self._mock_call(*args, **kwargs)
23+
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/unittest/mock.py", line 1097, in _mock_call
24+
return self._execute_mock_call(*args, **kwargs)
25+
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/unittest/mock.py", line 1152, in _execute_mock_call
26+
raise effect
27+
Exception: API Error
28+
2025-03-13 18:05:17,829 - INFO - Successfully loaded credentials
29+
2025-03-13 18:05:17,829 - INFO - Successfully created Google Sheets service
30+
2025-03-13 18:05:17,829 - ERROR - No data found in the sheet
31+
2025-03-13 18:05:17,830 - INFO - Successfully loaded credentials
32+
2025-03-13 18:05:17,830 - INFO - Successfully created Google Sheets service
33+
2025-03-13 18:05:17,831 - INFO - Retrieved 1 rows of data
34+
2025-03-13 18:05:17,834 - WARNING - Column 'Autonomy Rating' not found in sheet
35+
2025-03-13 18:05:17,834 - WARNING - Column 'Experience Rating' not found in sheet
36+
2025-03-13 18:05:17,834 - WARNING - Column 'Output Quality Rating' not found in sheet
37+
2025-03-13 18:05:17,834 - WARNING - Column 'Overall Satisfaction' not found in sheet
38+
2025-03-13 18:05:17,834 - WARNING - Column 'Unique ID' not found in sheet
39+
2025-03-13 18:05:17,834 - WARNING - Column 'POD' not found in sheet
40+
2025-03-13 18:05:17,835 - INFO - Successfully filtered required columns
41+
2025-03-13 18:10:37,427 - INFO - Successfully loaded credentials
42+
2025-03-13 18:10:37,427 - INFO - Successfully created Google Sheets service
43+
2025-03-13 18:10:37,428 - ERROR - An error occurred: API Error
44+
Traceback (most recent call last):
45+
File "/Users/surya.sandeep.boda/Desktop/Marscode Zero to One 3/extract_data.py", line 44, in get_google_sheet_data
46+
result = sheet.values().get(
47+
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/unittest/mock.py", line 1093, in __call__
48+
return self._mock_call(*args, **kwargs)
49+
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/unittest/mock.py", line 1097, in _mock_call
50+
return self._execute_mock_call(*args, **kwargs)
51+
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/unittest/mock.py", line 1152, in _execute_mock_call
52+
raise effect
53+
Exception: API Error
54+
2025-03-13 18:10:37,430 - INFO - Successfully loaded credentials
55+
2025-03-13 18:10:37,430 - INFO - Successfully created Google Sheets service
56+
2025-03-13 18:10:37,430 - ERROR - No data found in the sheet
57+
2025-03-13 18:10:37,431 - INFO - Successfully loaded credentials
58+
2025-03-13 18:10:37,431 - INFO - Successfully created Google Sheets service
59+
2025-03-13 18:10:37,434 - INFO - Retrieved 1 rows of data
60+
2025-03-13 18:10:37,436 - WARNING - Column 'Autonomy Rating' not found in sheet
61+
2025-03-13 18:10:37,436 - WARNING - Column 'Experience Rating' not found in sheet
62+
2025-03-13 18:10:37,436 - WARNING - Column 'Output Quality Rating' not found in sheet
63+
2025-03-13 18:10:37,436 - WARNING - Column 'Overall Satisfaction' not found in sheet
64+
2025-03-13 18:10:37,436 - WARNING - Column 'Unique ID' not found in sheet
65+
2025-03-13 18:10:37,436 - WARNING - Column 'POD' not found in sheet
66+
2025-03-13 18:10:37,437 - INFO - Successfully filtered required columns
67+
2025-03-13 18:15:32,290 - INFO - Successfully loaded credentials
68+
2025-03-13 18:15:32,291 - INFO - file_cache is only supported with oauth2client<4.0.0
69+
2025-03-13 18:15:32,292 - INFO - Successfully created Google Sheets service
70+
2025-03-13 18:15:35,144 - INFO - Retrieved 144 rows of data
71+
2025-03-13 18:15:35,147 - WARNING - Column 'Tool Used' not found in sheet
72+
2025-03-13 18:15:35,147 - WARNING - Column 'Feature' not found in sheet
73+
2025-03-13 18:15:35,147 - WARNING - Column 'Context Awareness Rating' not found in sheet
74+
2025-03-13 18:15:35,147 - WARNING - Column 'Autonomy Rating' not found in sheet
75+
2025-03-13 18:15:35,147 - WARNING - Column 'Experience Rating' not found in sheet
76+
2025-03-13 18:15:35,147 - WARNING - Column 'Output Quality Rating' not found in sheet
77+
2025-03-13 18:15:35,147 - WARNING - Column 'Overall Satisfaction' not found in sheet
78+
2025-03-13 18:15:35,148 - WARNING - Column 'POD' not found in sheet
79+
2025-03-13 18:15:35,150 - INFO - Successfully filtered required columns
80+
2025-03-13 18:15:35,151 - INFO - Data retrieval successful
81+
2025-03-13 18:17:11,477 - INFO - Successfully loaded credentials
82+
2025-03-13 18:17:11,478 - INFO - file_cache is only supported with oauth2client<4.0.0
83+
2025-03-13 18:17:11,479 - INFO - Successfully created Google Sheets service
84+
2025-03-13 18:17:13,625 - INFO - Retrieved 144 rows of data
85+
2025-03-13 18:17:13,625 - INFO - Available columns in sheet: ['Timestamp', 'Email Address', 'Tool being used', 'Feature used', 'Task Objective', 'Repository Link', 'Repository: Public/Private', 'Repository: Lines of Code', '[Turn 1]: Prompt Category', '[Turn 1]: Prompt', '[Turn 1]: Model Response', '[Turn 1]: Model Response - File [Use only when response is too long]', '[Turn 1]: Observations', '[Turn 1]: Screenshots', '[Turn 2]: Prompt Category', '[Turn 2]: Prompt', '[Turn 2]: Model Response', '[Turn 2]: Model Response - File [Use only when response is too long]', '[Turn 2]: Observations', '[Turn 2]: Screenshot', '[Turn 3]: Prompt Category', '[Turn 3]: Prompt', '[Turn 3]: Model Response', '[Turn 3]: Model Response - File [Use only when response is too long]', '[Turn 3]: Observations', '[Turn 3]: Screenshot', '[Turn 4]: Prompt Category', '[Turn 4]: Prompt', '[Turn 4]: Model Response', '[Turn 4]: Model Response - File [Use only when response is too long]', '[Turn 4]: Observations', '[Turn 4]: Screenshot', '[Turn 5]: Prompt Category', '[Turn 5]: Prompt', '[Turn 5]: Model Response', '[Turn 5]: Model Response - File [Use only when response is too long]', '[Turn 5]: Observations', '[Turn 5]: Screenshot', '[Turn 6]: Prompt Category', '[Turn 6]: Prompt', '[Turn 6]: Model Response', '[Turn 6]: Model Response - File [Use only when response is too long]', '[Turn 6]: Observations', '[Turn 6]: Screenshot', '[Turn 7]: Prompt Category', '[Turn 7]: Prompt', '[Turn 7]: Model Response', '[Turn 7]: Model Response - File [Use only when response is too long]', '[Turn 7]: Observations', '[Turn 7]: Screenshot', 'Context Awareness', 'Context Awareness: Errors', 'Rationale for Context Awareness', 'Output Quality', 'Output Quality: Errors', 'Rationale for Output Quality', 'Autonomy', 'Autonomy: Errors', 'Rationale for Autonomy', 'Iteration Size and Speed', 'Iteration Size and Speed: Errors', 'Rationale for Iteration Size and Speed', 'Experience', 'Experience - Flexibility, Ease of Use and Reliability: Errors', 'Rationale for Experience', 'Loom Recording Link', 'Overall Rating', 'Rationale behind the overall rating', '[Turn 1]: Final Turn?', '[Turn 2]: Final Turn?', '[Turn 3]: Final Turn?', '[Turn 4]: Final Turn?', '[Turn 5]: Final Turn?', '[Turn 6]: Final Turn?', '[Turn 7]: Final Turn?', '[Turn 1]: Turn ID', '[Turn 2]: Turn ID', '[Turn 3]: Turn ID', '[Turn 4]: Turn ID', '[Turn 5]: Turn ID', '[Turn 6]: Turn ID', '[Turn 7]: Turn ID', 'Unique ID']
86+
2025-03-13 18:17:13,627 - WARNING - Column 'Tool Used' not found in sheet
87+
2025-03-13 18:17:13,627 - WARNING - Column 'Feature' not found in sheet
88+
2025-03-13 18:17:13,627 - WARNING - Column 'Context Awareness Rating' not found in sheet
89+
2025-03-13 18:17:13,628 - WARNING - Column 'Autonomy Rating' not found in sheet
90+
2025-03-13 18:17:13,628 - WARNING - Column 'Experience Rating' not found in sheet
91+
2025-03-13 18:17:13,628 - WARNING - Column 'Output Quality Rating' not found in sheet
92+
2025-03-13 18:17:13,628 - WARNING - Column 'Overall Satisfaction' not found in sheet
93+
2025-03-13 18:17:13,628 - WARNING - Column 'POD' not found in sheet
94+
2025-03-13 18:17:13,630 - INFO - Successfully filtered required columns
95+
2025-03-13 18:17:13,631 - INFO - Data retrieval successful
96+
2025-03-13 18:19:11,025 - INFO - Successfully loaded credentials
97+
2025-03-13 18:19:11,027 - INFO - file_cache is only supported with oauth2client<4.0.0
98+
2025-03-13 18:19:11,029 - INFO - Successfully created Google Sheets service
99+
2025-03-13 18:19:13,585 - INFO - Retrieved 144 rows of data
100+
2025-03-13 18:19:13,585 - INFO - Available columns in sheet: ['Timestamp', 'Email Address', 'Tool being used', 'Feature used', 'Task Objective', 'Repository Link', 'Repository: Public/Private', 'Repository: Lines of Code', '[Turn 1]: Prompt Category', '[Turn 1]: Prompt', '[Turn 1]: Model Response', '[Turn 1]: Model Response - File [Use only when response is too long]', '[Turn 1]: Observations', '[Turn 1]: Screenshots', '[Turn 2]: Prompt Category', '[Turn 2]: Prompt', '[Turn 2]: Model Response', '[Turn 2]: Model Response - File [Use only when response is too long]', '[Turn 2]: Observations', '[Turn 2]: Screenshot', '[Turn 3]: Prompt Category', '[Turn 3]: Prompt', '[Turn 3]: Model Response', '[Turn 3]: Model Response - File [Use only when response is too long]', '[Turn 3]: Observations', '[Turn 3]: Screenshot', '[Turn 4]: Prompt Category', '[Turn 4]: Prompt', '[Turn 4]: Model Response', '[Turn 4]: Model Response - File [Use only when response is too long]', '[Turn 4]: Observations', '[Turn 4]: Screenshot', '[Turn 5]: Prompt Category', '[Turn 5]: Prompt', '[Turn 5]: Model Response', '[Turn 5]: Model Response - File [Use only when response is too long]', '[Turn 5]: Observations', '[Turn 5]: Screenshot', '[Turn 6]: Prompt Category', '[Turn 6]: Prompt', '[Turn 6]: Model Response', '[Turn 6]: Model Response - File [Use only when response is too long]', '[Turn 6]: Observations', '[Turn 6]: Screenshot', '[Turn 7]: Prompt Category', '[Turn 7]: Prompt', '[Turn 7]: Model Response', '[Turn 7]: Model Response - File [Use only when response is too long]', '[Turn 7]: Observations', '[Turn 7]: Screenshot', 'Context Awareness', 'Context Awareness: Errors', 'Rationale for Context Awareness', 'Output Quality', 'Output Quality: Errors', 'Rationale for Output Quality', 'Autonomy', 'Autonomy: Errors', 'Rationale for Autonomy', 'Iteration Size and Speed', 'Iteration Size and Speed: Errors', 'Rationale for Iteration Size and Speed', 'Experience', 'Experience - Flexibility, Ease of Use and Reliability: Errors', 'Rationale for Experience', 'Loom Recording Link', 'Overall Rating', 'Rationale behind the overall rating', '[Turn 1]: Final Turn?', '[Turn 2]: Final Turn?', '[Turn 3]: Final Turn?', '[Turn 4]: Final Turn?', '[Turn 5]: Final Turn?', '[Turn 6]: Final Turn?', '[Turn 7]: Final Turn?', '[Turn 1]: Turn ID', '[Turn 2]: Turn ID', '[Turn 3]: Turn ID', '[Turn 4]: Turn ID', '[Turn 5]: Turn ID', '[Turn 6]: Turn ID', '[Turn 7]: Turn ID', 'Unique ID']
101+
2025-03-13 18:19:13,590 - INFO - Successfully filtered required columns
102+
2025-03-13 18:19:13,591 - INFO - Data retrieval successful

extract_data.py

+58-11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from googleapiclient.discovery import build
77
import pandas as pd
88
import logging
9+
import numpy as np
910

1011
# Configure logging
1112
logging.basicConfig(
@@ -57,20 +58,19 @@ def get_google_sheet_data():
5758
LOGGER.info("Retrieved %d rows of data", len(df_data))
5859

5960
# Log available columns for debugging
60-
LOGGER.debug("Available columns in sheet: %s", list(df_data.columns))
61+
LOGGER.info("Available columns in sheet: %s", list(df_data.columns))
6162

6263
# Column mapping configuration
6364
column_mapping = {
64-
'Email Address': 'Email address',
65-
'Tool Used': 'Tool being used',
66-
'Feature': 'Feature used',
67-
'Context Awareness Rating': 'Context Awareness',
68-
'Autonomy Rating': 'Autonomy',
69-
'Experience Rating': 'Experience',
70-
'Output Quality Rating': 'Output Quality',
71-
'Overall Satisfaction': 'Overall Rating',
72-
'Unique ID': 'Unique ID',
73-
'POD': 'Pod'
65+
'Email Address': 'Email Address',
66+
'Tool being used': 'Tool being used',
67+
'Feature used': 'Feature used',
68+
'Context Awareness': 'Context Awareness',
69+
'Autonomy': 'Autonomy',
70+
'Experience': 'Experience',
71+
'Output Quality': 'Output Quality',
72+
'Overall Rating': 'Overall Rating',
73+
'Unique ID': 'Unique ID'
7474
}
7575

7676
# Process columns
@@ -86,6 +86,46 @@ def get_google_sheet_data():
8686
filtered_df = df_data[required_columns]
8787
LOGGER.info("Successfully filtered required columns")
8888

89+
# After getting filtered_df, add calculations
90+
rating_columns = ['Context Awareness', 'Autonomy', 'Experience', 'Output Quality']
91+
92+
# Convert rating columns to numeric
93+
for col in rating_columns + ['Overall Rating']:
94+
filtered_df[col] = pd.to_numeric(filtered_df[col], errors='coerce')
95+
96+
# Calculate Mean Rating
97+
filtered_df['Mean Rating'] = filtered_df[rating_columns].mean(axis=1)
98+
LOGGER.info("Calculated mean ratings")
99+
100+
# Calculate difference
101+
filtered_df['Difference'] = filtered_df['Mean Rating'] - filtered_df['Overall Rating']
102+
103+
# Determine Result status
104+
def get_result_status(difference):
105+
if -1 <= difference <= 1:
106+
return 'Ok'
107+
return 'Not ok'
108+
109+
filtered_df['Result'] = filtered_df['Difference'].apply(get_result_status)
110+
111+
# Create color mapping for results
112+
filtered_df['Result_Color'] = filtered_df['Result'].map({
113+
'Ok': 'green',
114+
'Not ok': 'red'
115+
})
116+
117+
LOGGER.info("Calculated results and color mapping")
118+
119+
# Reorder columns
120+
final_columns = [
121+
'Email Address', 'Tool being used', 'Feature used',
122+
'Context Awareness', 'Autonomy', 'Experience', 'Output Quality',
123+
'Overall Rating', 'Mean Rating', 'Difference', 'Result',
124+
'Unique ID'
125+
]
126+
127+
filtered_df = filtered_df[final_columns]
128+
89129
return filtered_df
90130

91131
except Exception as error:
@@ -97,6 +137,13 @@ def get_google_sheet_data():
97137
if result_data is not None:
98138
LOGGER.info("Data retrieval successful")
99139
print("\nFirst 5 rows of retrieved data:")
140+
pd.set_option('display.max_columns', None) # Show all columns
100141
print(result_data.head())
142+
143+
# Print summary statistics
144+
print("\nSummary Statistics:")
145+
print(f"Total Records: {len(result_data)}")
146+
print(f"Ok Results: {len(result_data[result_data['Result'] == 'Ok'])}")
147+
print(f"Not Ok Results: {len(result_data[result_data['Result'] == 'Not ok'])}")
101148
else:
102149
LOGGER.error("Failed to retrieve data")

0 commit comments

Comments
 (0)