Update app.py
Browse files
app.py
CHANGED
|
@@ -76,19 +76,9 @@ engagement_df['posting_time'] = pd.to_datetime(engagement_df['posting_time'], fo
|
|
| 76 |
# Ensure 'caption' is treated as a string column in solved data
|
| 77 |
solved_df['caption'] = solved_df['caption'].astype(str)
|
| 78 |
|
| 79 |
-
# Extract hashtags from the
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
# Convert the caption string to a dictionary
|
| 83 |
-
caption_dict = ast.literal_eval(caption)
|
| 84 |
-
# Extract hashtags if they exist
|
| 85 |
-
return caption_dict.get('hashtags', [])
|
| 86 |
-
except (ValueError, SyntaxError):
|
| 87 |
-
# Handle cases where caption is not a valid dictionary
|
| 88 |
-
return []
|
| 89 |
-
|
| 90 |
-
# Apply the function to the caption column
|
| 91 |
-
solved_df['hashtags'] = solved_df['caption'].apply(extract_hashtags)
|
| 92 |
|
| 93 |
# Filter out rows with invalid posting_time in engagement data
|
| 94 |
engagement_df = engagement_df[engagement_df['posting_time'].notna()]
|
|
|
|
| 76 |
# Ensure 'caption' is treated as a string column in solved data
|
| 77 |
solved_df['caption'] = solved_df['caption'].astype(str)
|
| 78 |
|
| 79 |
+
# Extract hashtags from the solved data (already provided as a list)
|
| 80 |
+
logging.info("Extracting hashtags from solved data...")
|
| 81 |
+
solved_df['hashtags'] = solved_df['hashtags'].apply(lambda x: x if isinstance(x, list) else [])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
# Filter out rows with invalid posting_time in engagement data
|
| 84 |
engagement_df = engagement_df[engagement_df['posting_time'].notna()]
|