Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Created August 28, 2018 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chelseatroy/d2fc284d6c96ecfa9c699791a9ccb715 to your computer and use it in GitHub Desktop.
Save chelseatroy/d2fc284d6c96ecfa9c699791a9ccb715 to your computer and use it in GitHub Desktop.
Example of Proxy Model InfectionRateVisualization
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