Forked from chelseatroy/infection_rate_visualization.py
Created
March 18, 2021 05:23
-
-
Save alimp5/bb50e4a2643c62cad3571702253ecce2 to your computer and use it in GitHub Desktop.
Example of Proxy Model InfectionRateVisualization
This file contains 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