MohanadAfiffy commited on
Commit
9fb2486
·
verified ·
1 Parent(s): 78c8795

Add pct change

Browse files
Files changed (1) hide show
  1. clients.py +23 -6
clients.py CHANGED
@@ -426,11 +426,28 @@ def display_analytics():
426
  rengagement_df = fetch_analytics_data(rengagement_host, start_date, end_date)
427
  hook_df = fetch_analytics_data(hook_host, start_date, end_date)
428
 
429
- st.html('<h4 class="hero-subtitle">Cold Emails</h4>')
430
- st.dataframe(cold_df)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
431
 
432
- st.html('<h4 class="hero-subtitle">Re-engagement Emails</h4>')
433
- st.dataframe(rengagement_df)
 
434
 
435
- st.html('<h4 class="hero-subtitle">Re-engagement Hooks "Hook2Lead"</h4>')
436
- st.dataframe(hook_df)
 
 
426
  rengagement_df = fetch_analytics_data(rengagement_host, start_date, end_date)
427
  hook_df = fetch_analytics_data(hook_host, start_date, end_date)
428
 
429
+ # Calculate percentage change for each dataframe
430
+ def calculate_percentage_change(df):
431
+ df = df.sort_values(by=['email_receiver', 'week']) # Ensure data is sorted by week
432
+ df['Percentage Change'] = df.groupby('email_receiver')['Total Companies/Executives engaged'].pct_change() * 100
433
+ df['Percentage Change'] = df['Percentage Change'].fillna('No Data') # Handle NaN values
434
+ return df
435
+
436
+ cold_df = calculate_percentage_change(cold_df)
437
+ rengagement_df = calculate_percentage_change(rengagement_df)
438
+ hook_df = calculate_percentage_change(hook_df)
439
+
440
+ # Display dataframes side by side
441
+ col1, col2, col3 = st.columns(3)
442
+
443
+ with col1:
444
+ st.html('<h4 class="hero-subtitle">Cold Emails</h4>')
445
+ st.dataframe(cold_df)
446
 
447
+ with col2:
448
+ st.html('<h4 class="hero-subtitle">Re-engagement Emails</h4>')
449
+ st.dataframe(rengagement_df)
450
 
451
+ with col3:
452
+ st.html('<h4 class="hero-subtitle">Re-engagement Hooks "Hook2Lead"</h4>')
453
+ st.dataframe(hook_df)