|
|
import pandas as pd |
|
|
from utils.visualization import plot_engagement_heatmap, plot_engagement_over_time |
|
|
from utils.preprocessing import preprocess_data |
|
|
|
|
|
def analyze_engagement(): |
|
|
"""Analyze engagement data.""" |
|
|
|
|
|
df = pd.read_json("data/raw/engagement_metrics.json") |
|
|
df = preprocess_data(df) |
|
|
|
|
|
|
|
|
df['hour'] = df['posting_time'].dt.hour |
|
|
engagement_by_hour = df.groupby('hour')['engagement_rate'].mean().reset_index() |
|
|
plot_engagement_heatmap(engagement_by_hour) |
|
|
|
|
|
|
|
|
engagement_summary = df.groupby('posting_time').agg({'engagement_rate': 'mean'}).reset_index() |
|
|
plot_engagement_over_time(engagement_summary) |