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,34 +137,22 @@ def __get_number_of_projects(df):
128137
129138 return len (df ["project" ].unique ())
130139
131- import squarify
132- import urllib .request
133- import matplotlib .pyplot as plt
134- import pandas as pd
135- '''
136- Import modules to create treemap of the frenquency of projects in the dataset
137- '''
138- url = 'https://download.brainimagelibrary.org/inventory/daily/reports/today.json'
139- file_path , _ = urllib .request .urlretrieve (url )
140- df = pd .read_json (file_path )
141- '''
142- Link for the data that will be used
143- '''
144- def get_projects_treemaps (df ):
145- '''
146- name function for treemap of projects
147- '''
148- df = df ['project' ].value_counts ().to_dict ()
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 ()
149150 sizes_list = list (df .values ())
150151 names_list = list (df .keys ())
151152 squarify .plot (sizes_list )
152- plt .show ()
153- '''
154- Input: project values
155- Output: treemap graph of projects frequency
156- Created a code for the visualization of projects frequency
157- '''
158- get_projects_treemaps (df )
153+
154+ filename = f'treemap-projects-{ datetime .now ().strftime ("%Y%m%d" )} .png'
155+ plt .savefig ("path/to/save/plot.png" )
159156
160157
161158def report ():
@@ -183,4 +180,7 @@ def report():
183180 report ["technique" ] = __get_technique (df )
184181 report ["locations" ] = __get_locations (df )
185182
183+ # plots
184+ get_projects_treemap (df )
185+
186186 return report
0 commit comments