Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -462,7 +462,7 @@ def nlp_pipeline(original_df):
|
|
| 462 |
# Create cluster dataframes
|
| 463 |
budget_cluster_df, problem_cluster_df = create_cluster_dataframes(processed_df)
|
| 464 |
|
| 465 |
-
return processed_df, budget_cluster_df
|
| 466 |
|
| 467 |
# # # Generate project proposals
|
| 468 |
# # location_clusters = dict(enumerate(processed_df['Location_Category_Words'].unique()))
|
|
@@ -491,7 +491,7 @@ def process_excel(file):
|
|
| 491 |
# Process the DataFrame
|
| 492 |
console_messages.append("Processing the DataFrame...")
|
| 493 |
# processed_df, budget_cluster_df, problem_cluster_df, project_proposals, location_clusters, problem_clusters = nlp_pipeline(df)
|
| 494 |
-
processed_df
|
| 495 |
|
| 496 |
output_filename = "OutPut_PPs.xlsx"
|
| 497 |
with pd.ExcelWriter(output_filename) as writer:
|
|
@@ -502,9 +502,23 @@ def process_excel(file):
|
|
| 502 |
# project_proposals_df.to_excel(writer, sheet_name='Project_Proposals', index=False)
|
| 503 |
|
| 504 |
budget_cluster_df.to_excel(writer, sheet_name='Financial_Weights')
|
| 505 |
-
|
| 506 |
processed_df.to_excel(writer, sheet_name='Input_Processed', index=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 507 |
|
|
|
|
| 508 |
console_messages.append("Processing completed. Ready for download.")
|
| 509 |
return output_filename, "\n".join(console_messages) # Return the processed DataFrame as Excel file
|
| 510 |
|
|
|
|
| 462 |
# Create cluster dataframes
|
| 463 |
budget_cluster_df, problem_cluster_df = create_cluster_dataframes(processed_df)
|
| 464 |
|
| 465 |
+
return processed_df, budget_cluster_df, problem_cluster_df, location_clusters, problem_clusters
|
| 466 |
|
| 467 |
# # # Generate project proposals
|
| 468 |
# # location_clusters = dict(enumerate(processed_df['Location_Category_Words'].unique()))
|
|
|
|
| 491 |
# Process the DataFrame
|
| 492 |
console_messages.append("Processing the DataFrame...")
|
| 493 |
# processed_df, budget_cluster_df, problem_cluster_df, project_proposals, location_clusters, problem_clusters = nlp_pipeline(df)
|
| 494 |
+
processed_df, budget_cluster_df, problem_cluster_df, location_clusters, problem_clusters = nlp_pipeline(df)
|
| 495 |
|
| 496 |
output_filename = "OutPut_PPs.xlsx"
|
| 497 |
with pd.ExcelWriter(output_filename) as writer:
|
|
|
|
| 502 |
# project_proposals_df.to_excel(writer, sheet_name='Project_Proposals', index=False)
|
| 503 |
|
| 504 |
budget_cluster_df.to_excel(writer, sheet_name='Financial_Weights')
|
| 505 |
+
problem_cluster_df.to_excel(writer, sheet_name='Problem_Descriptions')
|
| 506 |
processed_df.to_excel(writer, sheet_name='Input_Processed', index=False)
|
| 507 |
+
|
| 508 |
+
# Ensure location_clusters and problem_clusters are in DataFrame format
|
| 509 |
+
if isinstance(location_clusters, pd.DataFrame):
|
| 510 |
+
location_clusters.to_excel(writer, sheet_name='Location_Clusters', index=False)
|
| 511 |
+
else:
|
| 512 |
+
console_messages.append("Converting Location Clusters to df")
|
| 513 |
+
pd.DataFrame(location_clusters).to_excel(writer, sheet_name='Location_Clusters', index=False)
|
| 514 |
+
if isinstance(problem_clusters, pd.DataFrame):
|
| 515 |
+
problem_clusters.to_excel(writer, sheet_name='Problem_Clusters', index=False)
|
| 516 |
+
else:
|
| 517 |
+
console_messages.append("Converting Problem Clusters to df")
|
| 518 |
+
pd.DataFrame(problem_clusters).to_excel(writer, sheet_name='Problem_Clusters', index=False)
|
| 519 |
+
|
| 520 |
|
| 521 |
+
|
| 522 |
console_messages.append("Processing completed. Ready for download.")
|
| 523 |
return output_filename, "\n".join(console_messages) # Return the processed DataFrame as Excel file
|
| 524 |
|