File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -184,3 +184,28 @@ def report():
184
184
get_projects_treemap (df )
185
185
186
186
return report
187
+
188
+ # Creates a segmented bar graph that shows the proportion of general modalities over the years.
189
+ # Dropped the null values (no creation dates)
190
+ df [~ df ['creation_date' ].isnull ()]
191
+ df ['dates' ] = pd .to_datetime (df ['creation_date' ])
192
+ df ['year' ] = df ['dates' ].dt .year
193
+ df = df .dropna (subset = ['year' ])
194
+ df ['year' ] = df ['year' ].astype (int )
195
+ grouped = df .groupby (df ['dates' ].dt .year )
196
+
197
+ import matplotlib .pyplot as plt
198
+
199
+ grouped = df .groupby (['year' , 'generalmodality' ]).size ().reset_index (name = 'count' )
200
+
201
+ pivot_df = grouped .pivot (index = 'year' , columns = 'generalmodality' , values = 'count' ).fillna (0 )
202
+
203
+ pivot_df .plot (kind = 'bar' , stacked = True )
204
+
205
+ plt .title ('General Modalities' )
206
+ plt .ylabel ('Number of Datasets' )
207
+ plt .xlabel ('Year' )
208
+ plt .xticks (rotation = 45 )
209
+ plt .tight_layout ()
210
+
211
+ plt .show ()
You can’t perform that action at this time.
0 commit comments