2
2
import pandas as pd
3
3
import json
4
4
from datetime import date
5
+ import squarify
6
+ import matplotlib .pyplot as plt
5
7
6
8
7
9
def today ():
@@ -54,26 +56,30 @@ def __get_contributor(df):
54
56
def __get_affilation (df ):
55
57
return df ["affiliation" ].value_counts ().to_dict ()
56
58
59
+
57
60
def __get_awards (df ):
58
61
return df ["award_number" ].unique ()
59
62
60
63
61
64
def __get_award_number (df ):
62
65
return df ["award_number" ].value_counts ().to_dict ()
63
66
67
+
64
68
def __get_species (df ):
65
69
return df ["species" ].value_counts ().to_dict ()
66
70
67
71
68
72
def __get_cnbtaxonomy (df ):
69
73
return df ["cnbtaxonomy" ].value_counts ().to_dict ()
70
74
75
+
71
76
def __get_genotypes (df ):
72
77
"""
73
78
Write documentation here.
74
79
"""
75
80
return df ["genotype" ].unique ()
76
81
82
+
77
83
def __get_genotype_frequency (df ):
78
84
"""
79
85
Write documentation here.
@@ -84,6 +90,7 @@ def __get_genotype_frequency(df):
84
90
def __get_generalmodality (df ):
85
91
return df ["generalmodality" ].value_counts ().to_dict ()
86
92
93
+
87
94
def __get_techniques (df ):
88
95
"""
89
96
Write documentation here.
@@ -97,9 +104,11 @@ def techniques_frequency(df):
97
104
"""
98
105
return df ["technique" ].value_counts ().to_dict ()
99
106
107
+
100
108
def __get_locations (df ):
101
109
return df ["locations" ].value_counts ().to_dict ()
102
110
111
+
103
112
def __get_contributors (df ):
104
113
"""
105
114
This returns an array of contributor names from the contributorname column.
@@ -128,34 +137,22 @@ def __get_number_of_projects(df):
128
137
129
138
return len (df ["project" ].unique ())
130
139
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 ()
149
150
sizes_list = list (df .values ())
150
151
names_list = list (df .keys ())
151
152
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" )
159
156
160
157
161
158
def report ():
@@ -183,4 +180,7 @@ def report():
183
180
report ["technique" ] = __get_technique (df )
184
181
report ["locations" ] = __get_locations (df )
185
182
183
+ # plots
184
+ get_projects_treemap (df )
185
+
186
186
return report
0 commit comments