Created
August 28, 2018 18:21
-
-
Save chelseatroy/d2fc284d6c96ecfa9c699791a9ccb715 to your computer and use it in GitHub Desktop.
Example of Proxy Model InfectionRateVisualization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from visualizations.models import Visualization | |
class InfectionRateVisualization(Visualization): | |
class Meta: | |
proxy = True | |
def from_data(csvfile): | |
department_instances = [] | |
infection_type = [] | |
with open csvfile as file: | |
if file["department"] and file["type"]: | |
department_instances = np.array(file["department"]) | |
infection_type = np.array(file["type"]) | |
else: | |
return IncompleteDataException("Please include a department and a type column in your CSV.") | |
map = HeatMap(list(zip(department_instances, infection_type))) | |
return map.to_svg() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment