Spaces:
Sleeping
Sleeping
SanskrutiChopade
commited on
Commit
·
f035349
1
Parent(s):
443b256
Initial commit
Browse files
app.py
CHANGED
|
@@ -209,12 +209,20 @@ def index():
|
|
| 209 |
faculty_df = pd.read_csv(faculty_file)
|
| 210 |
|
| 211 |
# Validate columns in faculty data
|
| 212 |
-
required_faculty_columns = {'Name', 'Department', 'Post', '
|
| 213 |
-
|
| 214 |
missing_faculty_columns = required_faculty_columns - set(faculty_df.columns)
|
| 215 |
if missing_faculty_columns:
|
| 216 |
return render_template('index.html',
|
| 217 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
|
| 219 |
# Calculate grades
|
| 220 |
faculty_df['Grade'] = faculty_df.apply(lambda row: calculate_grades(row, WEIGHTS), axis=1)
|
|
@@ -235,9 +243,9 @@ def index():
|
|
| 235 |
graph_data = [
|
| 236 |
{
|
| 237 |
"title": "Count of Faculty by Department",
|
| 238 |
-
"data": faculty_df['Department'].value_counts().reset_index(
|
| 239 |
-
"graph": lambda df: px.bar(df, x='
|
| 240 |
-
labels={'
|
| 241 |
"query": "Provide insights into the distribution of faculty across departments based on this data."
|
| 242 |
},
|
| 243 |
{
|
|
|
|
| 209 |
faculty_df = pd.read_csv(faculty_file)
|
| 210 |
|
| 211 |
# Validate columns in faculty data
|
| 212 |
+
required_faculty_columns = {'Name', 'Department', 'Post', 'Years_of_', 'Degree_He',
|
| 213 |
+
'Research_', 'Publication', 'Skills'}
|
| 214 |
missing_faculty_columns = required_faculty_columns - set(faculty_df.columns)
|
| 215 |
if missing_faculty_columns:
|
| 216 |
return render_template('index.html',
|
| 217 |
+
error=f"Error: The faculty CSV is missing the following columns: {', '.join(missing_faculty_columns)}")
|
| 218 |
+
|
| 219 |
+
# Update column references throughout the code
|
| 220 |
+
faculty_df = faculty_df.rename(columns={
|
| 221 |
+
'Years_of_': 'Years_of_Experience',
|
| 222 |
+
'Degree_He': 'Degree_Held',
|
| 223 |
+
'Research_': 'Research_Count',
|
| 224 |
+
'Publication': 'Publications_Count'
|
| 225 |
+
})
|
| 226 |
|
| 227 |
# Calculate grades
|
| 228 |
faculty_df['Grade'] = faculty_df.apply(lambda row: calculate_grades(row, WEIGHTS), axis=1)
|
|
|
|
| 243 |
graph_data = [
|
| 244 |
{
|
| 245 |
"title": "Count of Faculty by Department",
|
| 246 |
+
"data": faculty_df['Department'].value_counts().reset_index(),
|
| 247 |
+
"graph": lambda df: px.bar(df, x='index', y='count', title="Count of Faculty by Department",
|
| 248 |
+
labels={'index': 'Department', 'count': 'Count'}),
|
| 249 |
"query": "Provide insights into the distribution of faculty across departments based on this data."
|
| 250 |
},
|
| 251 |
{
|