AliMustapha commited on
Commit
ea004be
·
1 Parent(s): 1dfa789

add overALL COUNTS OF commits to subregion mapping

Browse files
Files changed (1) hide show
  1. utils/plot.py +9 -2
utils/plot.py CHANGED
@@ -55,9 +55,16 @@ def get_commits_per_region(df,url):
55
 
56
  # Group by Year and sub-region-prediction, then count unique sub-regions
57
  sub_region_counts = df.groupby(['Year', "sub-region-prediction"])["sub-region-prediction"].count().reset_index(name='Count')
 
 
 
 
 
 
 
 
58
  # Merge the sub_region_counts DataFrame with the Country_to_region DataFrame
59
- merged_df = sub_region_counts.merge(Country_to_region, on="sub-region-prediction", how="left")
60
- color_max=df["sub-region-prediction"].value_counts().max()
61
  # Create a choropleth map using plotly.express
62
  fig = go.Figure(data=px.choropleth(
63
  merged_df,
 
55
 
56
  # Group by Year and sub-region-prediction, then count unique sub-regions
57
  sub_region_counts = df.groupby(['Year', "sub-region-prediction"])["sub-region-prediction"].count().reset_index(name='Count')
58
+ # Calculate the sums for each region
59
+ region_sums = sub_region_counts.groupby('sub-region-prediction')['Count'].sum().reset_index()
60
+
61
+ # Append 'All' rows to the DataFrame
62
+ df_all = region_sums.copy()
63
+ df_all['Year'] = 'Overall'
64
+ df_result = pd.concat([sub_region_counts, df_all], ignore_index=True, sort=False)
65
+
66
  # Merge the sub_region_counts DataFrame with the Country_to_region DataFrame
67
+ merged_df = df_result.merge(Country_to_region, on="sub-region-prediction", how="left")
 
68
  # Create a choropleth map using plotly.express
69
  fig = go.Figure(data=px.choropleth(
70
  merged_df,