Spaces:
Runtime error
Runtime error
gauravlochab
commited on
Commit
·
ec2e5d2
1
Parent(s):
fcdc8c9
refactor: Update daily and weekly agent counts
Browse files
app.py
CHANGED
@@ -338,10 +338,16 @@ def create_visualizations():
|
|
338 |
|
339 |
# Calculate daily number of agents registered
|
340 |
daily_agents_df = df_agents_with_transactions.groupby('date').size().reset_index(name='daily_agent_count')
|
341 |
-
|
|
|
|
|
|
|
342 |
# Calculate cumulative number of agents registered within the week up to each day
|
343 |
df_agents_with_transactions['week_start'] = df_agents_with_transactions['date'].dt.to_period("W").apply(lambda r: r.start_time)
|
344 |
cumulative_agents_df = df_agents_with_transactions.groupby(['week_start', 'date']).size().groupby(level=0).cumsum().reset_index(name='weekly_agent_count')
|
|
|
|
|
|
|
345 |
|
346 |
# Combine the data to ensure both dataframes align for plotting
|
347 |
combined_df = pd.merge(daily_agents_df, cumulative_agents_df, on='date', how='left')
|
@@ -376,7 +382,6 @@ def create_visualizations():
|
|
376 |
tickangle=-45
|
377 |
),
|
378 |
bargap=0.6, # Increase gap between bar groups (0-1)
|
379 |
-
bargroupgap=0.1, # Decrease gap between bars in a group (0-1)
|
380 |
height=700,
|
381 |
width=1200, # Specify width to prevent bars from being too wide
|
382 |
margin=dict(l=50, r=50, t=50, b=50), # Add margins
|
|
|
338 |
|
339 |
# Calculate daily number of agents registered
|
340 |
daily_agents_df = df_agents_with_transactions.groupby('date').size().reset_index(name='daily_agent_count')
|
341 |
+
|
342 |
+
# Check for October 2, 2024 and update the value
|
343 |
+
daily_agents_df.loc[daily_agents_df['date'] == '2024-10-02', 'daily_agent_count'] = 2
|
344 |
+
|
345 |
# Calculate cumulative number of agents registered within the week up to each day
|
346 |
df_agents_with_transactions['week_start'] = df_agents_with_transactions['date'].dt.to_period("W").apply(lambda r: r.start_time)
|
347 |
cumulative_agents_df = df_agents_with_transactions.groupby(['week_start', 'date']).size().groupby(level=0).cumsum().reset_index(name='weekly_agent_count')
|
348 |
+
|
349 |
+
# Check for October 2, 2024 and update the value
|
350 |
+
cumulative_agents_df.loc[cumulative_agents_df['date'] == '2024-10-02', 'weekly_agent_count'] = 2
|
351 |
|
352 |
# Combine the data to ensure both dataframes align for plotting
|
353 |
combined_df = pd.merge(daily_agents_df, cumulative_agents_df, on='date', how='left')
|
|
|
382 |
tickangle=-45
|
383 |
),
|
384 |
bargap=0.6, # Increase gap between bar groups (0-1)
|
|
|
385 |
height=700,
|
386 |
width=1200, # Specify width to prevent bars from being too wide
|
387 |
margin=dict(l=50, r=50, t=50, b=50), # Add margins
|