22import pandas as pd
33import json
44from datetime import date
5+ import squarify
6+ import matplotlib .pyplot as plt
57
68
79def today ():
@@ -54,26 +56,30 @@ def __get_contributor(df):
5456def __get_affilation (df ):
5557 return df ["affiliation" ].value_counts ().to_dict ()
5658
59+
5760def __get_awards (df ):
5861 return df ["award_number" ].unique ()
5962
6063
6164def __get_award_number (df ):
6265 return df ["award_number" ].value_counts ().to_dict ()
6366
67+
6468def __get_species (df ):
6569 return df ["species" ].value_counts ().to_dict ()
6670
6771
6872def __get_cnbtaxonomy (df ):
6973 return df ["cnbtaxonomy" ].value_counts ().to_dict ()
7074
75+
7176def __get_genotypes (df ):
7277 """
7378 Write documentation here.
7479 """
7580 return df ["genotype" ].unique ()
7681
82+
7783def __get_genotype_frequency (df ):
7884 """
7985 Write documentation here.
@@ -84,6 +90,7 @@ def __get_genotype_frequency(df):
8490def __get_generalmodality (df ):
8591 return df ["generalmodality" ].value_counts ().to_dict ()
8692
93+
8794def __get_techniques (df ):
8895 """
8996 Write documentation here.
@@ -97,9 +104,11 @@ def techniques_frequency(df):
97104 """
98105 return df ["technique" ].value_counts ().to_dict ()
99106
107+
100108def __get_locations (df ):
101109 return df ["locations" ].value_counts ().to_dict ()
102110
111+
103112def __get_contributors (df ):
104113 """
105114 This returns an array of contributor names from the contributorname column.
@@ -128,6 +137,24 @@ def __get_number_of_projects(df):
128137
129138 return len (df ["project" ].unique ())
130139
140+
141+ def get_projects_treemap (df ):
142+ """
143+ Created a code for the visualization of projects frequency
144+
145+ Input: project values
146+ Output: treemap graph of projects frequency
147+ """
148+
149+ df = df ["project" ].value_counts ().to_dict ()
150+ sizes_list = list (df .values ())
151+ names_list = list (df .keys ())
152+ squarify .plot (sizes_list )
153+
154+ filename = f'treemap-projects-{ datetime .now ().strftime ("%Y%m%d" )} .png'
155+ plt .savefig ("path/to/save/plot.png" )
156+
157+
131158def report ():
132159 # Get today's date
133160 tdate = date .today ()
@@ -153,4 +180,7 @@ def report():
153180 report ["technique" ] = __get_technique (df )
154181 report ["locations" ] = __get_locations (df )
155182
183+ # plots
184+ get_projects_treemap (df )
185+
156186 return report
0 commit comments