Instalación

Para el correcto funcionamiento del código realizado para este proyecto es necesario seguir las siguientes indicaciones:

  1. Instalar los paquetes beautifulsoup4 y Requests en Python:
    • pip install beautifulsoup4 Requests.
  2. Instalar Numpy.
    • sudo pip install numpy
  3. Instalar Ipython.
    • pip install ipython
  4. Instalar R.
    • apt install -y r-base
  5. Intalar Gnuplot.
    • apt -y install gnuplot
  6. Ahora, para dar soporte al uso de gnuplot en el notebook:
    • pip install --upgrade --no-cache-dir git+https://github.com/has2k1/gnuplot_kernel.git@master
  7. Clonar el repositorio:
    • git clone https://github.com/manuela98/Emergencias_911_.git

Inicialización

  • Dirijase a la carpeta Codigo y ejecute descarga.py para descargar el archivo tzr.csv que contienen los datos con los que se trabajara.

In [1]:
%%bash
python descarga.py
  • Para la extracción y manejo de datos se creó una matriz con los datos necesarios para su correcta consulta,esto se realiza con la función Datos_necesarios() ubicada en consultas.py

Consulta

Para realizar la consulta debe tener en cuenta los siguientes requerimientos:

  1. Escribir las siguientes lineas de código en una celda posterior a esta:

    from IPython.display import display, Markdown
    import consulta as c
    display(Markdown(c.Consulta()))

  2. Al ejecutar la celda, aparecerá un cuadro en el cuál deberá ingresar el tipo de dato que desea buscar. Inmediatamente despues aparecerá otro cuadro en donde debe ingresar lo que desea buscar. Las opciones son las siguites:

    • Tittle : Sí su búsqueda es por tipo de emergencia.
      • Ejemplos: EMS, Fire, Traffic
    • Description : Sí su búsqueda es por descripción de la emergencia.
      • Ejemplos: FALL VICTIM , RESPIRATORY EMERGENCY , VEHICLE ACCIDENT
    • Date : Sí su búsqueda es por le fecha en que ocurrió la llamada.
      • Ejemplos: 2015-12-10 , 2015-10-10
    • Hour : Sí su búsqueda es por la hora en que ocurrió la llamada.
      • Ejemplos: 08:07:00 , 08:47:13
  3. Si ha realizado la búsqueda de manera correcta se mostrará una tabla con las coincidencias del dato ingresado. la tabla le brindará una información completa que contiene Titulo, descripción, fecha y hora independientemente de cual haya sido el tipo de dato a buscar.

In [2]:
#Ejemplo 
from IPython.display import display, Markdown
import consulta as c
display(Markdown(c.mark(c.Consulta())))


Ingrese Tittle,Description,Date o Hour segun el dato que desea buscar: Date
Ingrese el dato que desea buscar: 2016-10-29
Buscando... Por favor espere.
Debido al tipo de dato este proceso puede tardar un par de minutos
Tittle Description Date Hour
Fire VEHICLE ACCIDENT 2016-10-29 00:07:00
EMS VEHICLE ACCIDENT 2016-10-29 00:07:01
Traffic VEHICLE ACCIDENT - 2016-10-29 00:07:02
EMS RESPIRATORY EMERGENCY 2016-10-29 00:17:00
EMS VEHICLE ACCIDENT 2016-10-29 00:17:00
Fire VEHICLE ACCIDENT 2016-10-29 00:17:00
Traffic VEHICLE ACCIDENT - 2016-10-29 00:17:02
Traffic VEHICLE ACCIDENT - 2016-10-29 00:22:01
EMS ABDOMINAL PAINS 2016-10-29 00:37:01
EMS VEHICLE ACCIDENT 2016-10-29 00:37:01
Traffic VEHICLE ACCIDENT - 2016-10-29 00:37:02
EMS RESPIRATORY EMERGENCY 2016-10-29 00:41:01
Traffic VEHICLE ACCIDENT - 2016-10-29 00:42:02
EMS ABDOMINAL PAINS 2016-10-29 00:47:01
Traffic DISABLED VEHICLE - 2016-10-29 00:47:02
Traffic VEHICLE ACCIDENT - 2016-10-29 00:47:02
EMS DIZZINESS 2016-10-29 00:52:01
EMS FALL VICTIM 2016-10-29 01:17:01
Fire UNKNOWN TYPE FIRE 2016-10-29 01:17:01
EMS HEAD INJURY 2016-10-29 01:17:02
EMS HEMORRHAGING 2016-10-29 01:17:02
EMS ALTERED MENTAL STATUS 2016-10-29 01:32:00
EMS OVERDOSE 2016-10-29 01:37:00
EMS SUBJECT IN PAIN 2016-10-29 01:37:00
Traffic VEHICLE ACCIDENT - 2016-10-29 01:37:01
EMS CVA/STROKE 2016-10-29 01:41:00
EMS ABDOMINAL PAINS 2016-10-29 01:42:00
EMS DIABETIC EMERGENCY 2016-10-29 01:47:00
EMS UNCONSCIOUS SUBJECT 2016-10-29 01:52:01
Fire FIRE ALARM 2016-10-29 02:02:00
Traffic VEHICLE ACCIDENT - 2016-10-29 02:02:00
Fire FIRE INVESTIGATION 2016-10-29 02:06:00
Fire FIRE INVESTIGATION 2016-10-29 02:12:01
EMS CVA/STROKE 2016-10-29 02:32:00
EMS ASSAULT VICTIM 2016-10-29 02:46:01
Fire VEHICLE FIRE 2016-10-29 02:52:00
Traffic VEHICLE FIRE - 2016-10-29 02:52:00
Fire CARBON MONOXIDE DETECTOR 2016-10-29 03:22:00
EMS OVERDOSE 2016-10-29 03:32:01
EMS RESPIRATORY EMERGENCY 2016-10-29 03:47:01
Traffic VEHICLE ACCIDENT - 2016-10-29 03:47:01
EMS SUBJECT IN PAIN 2016-10-29 03:52:01
EMS FALL VICTIM 2016-10-29 03:57:01
EMS UNCONSCIOUS SUBJECT 2016-10-29 04:01:00
EMS DIZZINESS 2016-10-29 04:12:01
Traffic VEHICLE ACCIDENT - 2016-10-29 04:22:01
Traffic VEHICLE ACCIDENT - 2016-10-29 04:26:00
Traffic DISABLED VEHICLE - 2016-10-29 04:36:00
EMS RESPIRATORY EMERGENCY 2016-10-29 04:37:00
Traffic DISABLED VEHICLE - 2016-10-29 04:37:00
EMS HEAD INJURY 2016-10-29 04:47:01
Traffic VEHICLE ACCIDENT - 2016-10-29 05:02:01
EMS ALTERED MENTAL STATUS 2016-10-29 05:07:01
EMS OVERDOSE 2016-10-29 05:27:00
EMS SEIZURES 2016-10-29 05:36:00
Fire RESCUE - ELEVATOR 2016-10-29 05:57:00
Fire BUILDING FIRE 2016-10-29 05:57:01
EMS RESPIRATORY EMERGENCY 2016-10-29 06:06:00
EMS FALL VICTIM 2016-10-29 06:12:01
Fire CARBON MONOXIDE DETECTOR 2016-10-29 06:12:01
Fire S/B AT HELICOPTER LANDING 2016-10-29 06:16:01
Fire FIRE ALARM 2016-10-29 06:22:00
EMS SEIZURES 2016-10-29 06:22:01
EMS NAUSEA/VOMITING 2016-10-29 06:26:00
EMS SUBJECT IN PAIN 2016-10-29 06:27:01
EMS HEAD INJURY 2016-10-29 06:32:01
Traffic VEHICLE ACCIDENT - 2016-10-29 06:32:02
Traffic VEHICLE ACCIDENT - 2016-10-29 06:36:01
EMS UNRESPONSIVE SUBJECT 2016-10-29 06:42:01
Traffic DISABLED VEHICLE - 2016-10-29 06:47:01
EMS LACERATIONS 2016-10-29 06:51:00
EMS FALL VICTIM 2016-10-29 06:52:00
EMS LACERATIONS 2016-10-29 06:52:00
Traffic VEHICLE ACCIDENT - 2016-10-29 07:07:02
EMS CARDIAC ARREST 2016-10-29 07:37:00
EMS FALL VICTIM 2016-10-29 07:37:00
EMS HEMORRHAGING 2016-10-29 07:42:01
Fire FIRE ALARM 2016-10-29 07:52:00
Fire FIRE ALARM 2016-10-29 07:57:00
EMS FALL VICTIM 2016-10-29 08:07:00
EMS FALL VICTIM 2016-10-29 08:07:00
EMS FALL VICTIM 2016-10-29 08:07:01
EMS BUILDING FIRE 2016-10-29 08:17:00
EMS FALL VICTIM 2016-10-29 08:21:00
EMS SUBJECT IN PAIN 2016-10-29 08:27:00
EMS RESPIRATORY EMERGENCY 2016-10-29 08:32:00
Fire FIRE INVESTIGATION 2016-10-29 08:47:00
EMS ASSAULT VICTIM 2016-10-29 09:02:00
EMS OVERDOSE 2016-10-29 09:12:01
Traffic DISABLED VEHICLE - 2016-10-29 09:12:02
Traffic VEHICLE ACCIDENT - 2016-10-29 09:17:01
EMS GENERAL WEAKNESS 2016-10-29 09:32:01
EMS RESPIRATORY EMERGENCY 2016-10-29 09:32:01
EMS SUBJECT IN PAIN 2016-10-29 09:36:00
EMS HEMORRHAGING 2016-10-29 09:42:00
EMS SYNCOPAL EPISODE 2016-10-29 09:42:01
Fire FIRE ALARM 2016-10-29 09:52:00
Traffic VEHICLE ACCIDENT - 2016-10-29 09:52:02
Traffic VEHICLE ACCIDENT - 2016-10-29 09:52:02
Traffic VEHICLE ACCIDENT - 2016-10-29 10:02:00
EMS CARDIAC ARREST 2016-10-29 10:07:00
Traffic DISABLED VEHICLE - 2016-10-29 10:07:01
Fire GAS-ODOR/LEAK 2016-10-29 10:11:00
Fire FIRE ALARM 2016-10-29 10:12:00
EMS HEMORRHAGING 2016-10-29 10:22:00
EMS CARDIAC EMERGENCY 2016-10-29 10:32:00
EMS SYNCOPAL EPISODE 2016-10-29 10:32:01
EMS HEAD INJURY 2016-10-29 10:37:01
EMS SUBJECT IN PAIN 2016-10-29 10:37:01
Traffic DISABLED VEHICLE - 2016-10-29 10:42:02
EMS ABDOMINAL PAINS 2016-10-29 10:52:01
EMS FALL VICTIM 2016-10-29 10:52:01
Traffic VEHICLE ACCIDENT - 2016-10-29 10:52:02
EMS VEHICLE ACCIDENT 2016-10-29 10:56:00
EMS HEMORRHAGING 2016-10-29 10:57:00
Traffic VEHICLE ACCIDENT - 2016-10-29 10:57:01
Traffic DISABLED VEHICLE - 2016-10-29 10:57:02
Traffic VEHICLE ACCIDENT - 2016-10-29 11:02:02
Traffic VEHICLE ACCIDENT - 2016-10-29 11:06:00
EMS VEHICLE ACCIDENT 2016-10-29 11:07:00
Traffic VEHICLE ACCIDENT - 2016-10-29 11:07:02
EMS CARDIAC ARREST 2016-10-29 11:12:01
Traffic VEHICLE ACCIDENT - 2016-10-29 11:21:01
EMS CARDIAC EMERGENCY 2016-10-29 11:22:00
EMS BACK PAINS/INJURY 2016-10-29 11:27:01
Fire FIRE ALARM 2016-10-29 11:27:01
Traffic ROAD OBSTRUCTION - 2016-10-29 11:27:02
EMS DIZZINESS 2016-10-29 11:37:01
Fire BUILDING FIRE 2016-10-29 11:37:01
Traffic VEHICLE ACCIDENT - 2016-10-29 11:37:02
Traffic VEHICLE ACCIDENT - 2016-10-29 11:37:02
EMS HEMORRHAGING 2016-10-29 11:42:00
Fire BUILDING FIRE 2016-10-29 11:42:00
Traffic VEHICLE ACCIDENT - 2016-10-29 11:42:01
EMS FRACTURE 2016-10-29 11:51:01
EMS ALLERGIC REACTION 2016-10-29 11:52:01
Traffic VEHICLE ACCIDENT - 2016-10-29 11:52:02
EMS CHOKING 2016-10-29 11:57:00
Traffic VEHICLE ACCIDENT - 2016-10-29 11:57:01
Traffic VEHICLE ACCIDENT - 2016-10-29 11:57:01
EMS RESPIRATORY EMERGENCY 2016-10-29 12:02:00
EMS GENERAL WEAKNESS 2016-10-29 12:02:01
EMS NAUSEA/VOMITING 2016-10-29 12:07:00
EMS SYNCOPAL EPISODE 2016-10-29 12:07:00
EMS UNKNOWN MEDICAL EMERGENCY 2016-10-29 12:12:00
EMS ALTERED MENTAL STATUS 2016-10-29 12:12:01
EMS GENERAL WEAKNESS 2016-10-29 12:12:01
EMS UNCONSCIOUS SUBJECT 2016-10-29 12:17:00
Traffic DISABLED VEHICLE - 2016-10-29 12:22:02
Traffic VEHICLE ACCIDENT - 2016-10-29 12:26:02
EMS MATERNITY 2016-10-29 12:36:01
Traffic VEHICLE ACCIDENT - 2016-10-29 12:37:01
EMS UNCONSCIOUS SUBJECT 2016-10-29 12:41:00
EMS UNCONSCIOUS SUBJECT 2016-10-29 12:42:00
Traffic HAZARDOUS ROAD CONDITIONS - 2016-10-29 12:42:02
EMS CVA/STROKE 2016-10-29 12:47:00
Fire VEHICLE FIRE 2016-10-29 12:47:00
Traffic VEHICLE ACCIDENT - 2016-10-29 12:47:02
Traffic VEHICLE FIRE - 2016-10-29 12:47:02
Fire RESCUE - ELEVATOR 2016-10-29 12:52:01
EMS FALL VICTIM 2016-10-29 12:52:02
Traffic VEHICLE ACCIDENT - 2016-10-29 12:52:03
Traffic ROAD OBSTRUCTION - 2016-10-29 12:56:34
Traffic VEHICLE ACCIDENT - 2016-10-29 12:56:34
EMS CVA/STROKE 2016-10-29 13:01:49
EMS VEHICLE ACCIDENT 2016-10-29 13:01:49
Traffic VEHICLE ACCIDENT - 2016-10-29 13:01:49
EMS BACK PAINS/INJURY 2016-10-29 13:07:02
EMS MEDICAL ALERT ALARM 2016-10-29 13:07:02
EMS FALL VICTIM 2016-10-29 13:07:03
EMS RESPIRATORY EMERGENCY 2016-10-29 13:12:16
EMS CVA/STROKE 2016-10-29 13:16:28
EMS FALL VICTIM 2016-10-29 13:16:28
Traffic VEHICLE ACCIDENT - 2016-10-29 13:16:29
Traffic HAZARDOUS ROAD CONDITIONS - 2016-10-29 13:16:30
Traffic VEHICLE ACCIDENT - 2016-10-29 13:16:30
EMS FALL VICTIM 2016-10-29 13:22:01
Fire FIRE ALARM 2016-10-29 13:22:01
Traffic ROAD OBSTRUCTION - 2016-10-29 13:22:02
Fire FIRE INVESTIGATION 2016-10-29 13:26:11
Traffic VEHICLE ACCIDENT - 2016-10-29 13:37:00
Traffic VEHICLE ACCIDENT - 2016-10-29 13:37:01
Fire UNKNOWN TYPE FIRE 2016-10-29 13:41:14
Traffic VEHICLE ACCIDENT - 2016-10-29 13:41:15
EMS RESPIRATORY EMERGENCY 2016-10-29 13:46:48
Traffic DISABLED VEHICLE - 2016-10-29 13:46:49
EMS ALTERED MENTAL STATUS 2016-10-29 13:51:06
EMS VEHICLE ACCIDENT 2016-10-29 13:51:06
Traffic DISABLED VEHICLE - 2016-10-29 13:51:07
Traffic VEHICLE ACCIDENT - 2016-10-29 13:51:07
Traffic VEHICLE ACCIDENT - 2016-10-29 13:51:07
EMS HEMORRHAGING 2016-10-29 13:56:43
EMS UNKNOWN MEDICAL EMERGENCY 2016-10-29 14:02:20
Traffic DISABLED VEHICLE - 2016-10-29 14:02:21
Traffic VEHICLE ACCIDENT - 2016-10-29 14:06:32
EMS ABDOMINAL PAINS 2016-10-29 14:12:07
Traffic VEHICLE ACCIDENT - 2016-10-29 14:12:08
EMS RESPIRATORY EMERGENCY 2016-10-29 14:16:11
Traffic VEHICLE ACCIDENT - 2016-10-29 14:16:11
Traffic VEHICLE ACCIDENT - 2016-10-29 14:26:00
EMS CARDIAC EMERGENCY 2016-10-29 14:27:22
Traffic VEHICLE ACCIDENT - 2016-10-29 14:36:18
Traffic VEHICLE ACCIDENT - 2016-10-29 14:36:18
Traffic VEHICLE ACCIDENT - 2016-10-29 14:41:39
Traffic VEHICLE ACCIDENT - 2016-10-29 14:46:53
Traffic VEHICLE ACCIDENT - 2016-10-29 14:46:53
EMS SYNCOPAL EPISODE 2016-10-29 14:52:06
EMS VEHICLE ACCIDENT 2016-10-29 14:52:06
Fire VEHICLE ACCIDENT 2016-10-29 14:52:06
Traffic VEHICLE ACCIDENT - 2016-10-29 14:52:07
Traffic VEHICLE ACCIDENT - 2016-10-29 14:52:07
EMS ALTERED MENTAL STATUS 2016-10-29 14:57:17
Traffic VEHICLE ACCIDENT - 2016-10-29 14:57:18
Traffic VEHICLE ACCIDENT - 2016-10-29 14:57:18
EMS VEHICLE ACCIDENT 2016-10-29 15:02:41
Fire VEHICLE ACCIDENT 2016-10-29 15:02:41
EMS ASSAULT VICTIM 2016-10-29 15:02:42
Traffic DISABLED VEHICLE - 2016-10-29 15:02:42
EMS ALTERED MENTAL STATUS 2016-10-29 15:06:15
Traffic VEHICLE ACCIDENT - 2016-10-29 15:06:16
Traffic VEHICLE ACCIDENT - 2016-10-29 15:06:16
Fire S/B AT HELICOPTER LANDING 2016-10-29 15:11:41
EMS SYNCOPAL EPISODE 2016-10-29 15:16:53
EMS VEHICLE ACCIDENT 2016-10-29 15:16:53
Traffic VEHICLE ACCIDENT - 2016-10-29 15:16:54
EMS CVA/STROKE 2016-10-29 15:22:12
Fire FIRE ALARM 2016-10-29 15:22:12
Traffic HAZARDOUS ROAD CONDITIONS - 2016-10-29 15:22:13
Traffic VEHICLE ACCIDENT - 2016-10-29 15:22:13
Fire ELECTRICAL FIRE OUTSIDE 2016-10-29 15:26:34
EMS VEHICLE ACCIDENT 2016-10-29 15:26:35
Traffic VEHICLE ACCIDENT - 2016-10-29 15:26:35
Fire FIRE ALARM 2016-10-29 15:32:01
Traffic VEHICLE ACCIDENT - 2016-10-29 15:32:02
Traffic DISABLED VEHICLE - 2016-10-29 15:32:03
EMS FALL VICTIM 2016-10-29 15:37:23
Traffic VEHICLE ACCIDENT - 2016-10-29 15:47:12
Traffic VEHICLE ACCIDENT - 2016-10-29 15:47:13
Traffic ROAD OBSTRUCTION - 2016-10-29 15:51:30
EMS ALLERGIC REACTION 2016-10-29 15:57:09
Traffic DISABLED VEHICLE - 2016-10-29 16:01:24
Traffic ROAD OBSTRUCTION - 2016-10-29 16:01:24
EMS FALL VICTIM 2016-10-29 16:07:01
EMS FALL VICTIM 2016-10-29 16:07:01
EMS SYNCOPAL EPISODE 2016-10-29 16:07:01
Traffic DISABLED VEHICLE - 2016-10-29 16:11:15
Traffic ROAD OBSTRUCTION - 2016-10-29 16:16:54
Traffic DISABLED VEHICLE - 2016-10-29 16:21:00
EMS LACERATIONS 2016-10-29 16:22:25
Fire BUILDING FIRE 2016-10-29 16:26:39
Fire VEHICLE ACCIDENT 2016-10-29 16:26:39
EMS VEHICLE ACCIDENT 2016-10-29 16:26:40
EMS CARDIAC EMERGENCY 2016-10-29 16:32:15
Fire WOODS/FIELD FIRE 2016-10-29 16:32:15
Traffic VEHICLE ACCIDENT - 2016-10-29 16:32:16
Traffic VEHICLE ACCIDENT - 2016-10-29 16:36:29
Fire FIRE ALARM 2016-10-29 16:46:16
EMS ABDOMINAL PAINS 2016-10-29 16:51:54
Fire FIRE ALARM 2016-10-29 16:51:54
EMS FALL VICTIM 2016-10-29 16:51:56
EMS HEMORRHAGING 2016-10-29 16:51:56
EMS MEDICAL ALERT ALARM 2016-10-29 16:56:07
Fire GAS-ODOR/LEAK 2016-10-29 16:56:07
Traffic DISABLED VEHICLE - 2016-10-29 16:56:08
EMS CARDIAC EMERGENCY 2016-10-29 17:01:41
Fire FIRE ALARM 2016-10-29 17:01:41
EMS VEHICLE ACCIDENT 2016-10-29 17:11:33
Traffic VEHICLE ACCIDENT - 2016-10-29 17:11:34
Traffic ROAD OBSTRUCTION - 2016-10-29 17:17:10
Traffic VEHICLE ACCIDENT - 2016-10-29 17:21:34
Traffic VEHICLE ACCIDENT - 2016-10-29 17:21:34
EMS RESPIRATORY EMERGENCY 2016-10-29 17:25:59
Fire FIRE ALARM 2016-10-29 17:31:55
Traffic DISABLED VEHICLE - 2016-10-29 17:42:34
EMS RESPIRATORY EMERGENCY 2016-10-29 17:47:08
Fire FIRE ALARM 2016-10-29 17:51:42
Traffic VEHICLE ACCIDENT - 2016-10-29 17:51:43
Traffic DISABLED VEHICLE - 2016-10-29 17:56:16
Fire CARBON MONOXIDE DETECTOR 2016-10-29 18:02:20
Traffic DISABLED VEHICLE - 2016-10-29 18:02:21
EMS SUBJECT IN PAIN 2016-10-29 18:06:58
EMS ABDOMINAL PAINS 2016-10-29 18:06:59
EMS MEDICAL ALERT ALARM 2016-10-29 18:11:35
Fire FIRE ALARM 2016-10-29 18:11:35
Traffic VEHICLE ACCIDENT - 2016-10-29 18:11:36
EMS CARDIAC EMERGENCY 2016-10-29 18:16:09
EMS FALL VICTIM 2016-10-29 18:16:10
Traffic VEHICLE ACCIDENT - 2016-10-29 18:16:10
EMS RESPIRATORY EMERGENCY 2016-10-29 18:22:15
EMS SEIZURES 2016-10-29 18:22:15
EMS ALTERED MENTAL STATUS 2016-10-29 18:26:46
EMS RESPIRATORY EMERGENCY 2016-10-29 18:26:46
Fire FIRE ALARM 2016-10-29 18:31:16
Traffic VEHICLE ACCIDENT - 2016-10-29 18:31:17
Traffic DISABLED VEHICLE - 2016-10-29 18:37:15
EMS FALL VICTIM 2016-10-29 18:41:44
EMS VEHICLE ACCIDENT 2016-10-29 18:46:11
Traffic VEHICLE ACCIDENT - 2016-10-29 18:46:12
EMS BACK PAINS/INJURY 2016-10-29 18:52:15
Fire VEHICLE ACCIDENT 2016-10-29 18:52:15
Traffic DISABLED VEHICLE - 2016-10-29 18:52:16
Fire VEHICLE ACCIDENT 2016-10-29 18:56:43
EMS VEHICLE ACCIDENT 2016-10-29 18:56:44
Traffic VEHICLE ACCIDENT - 2016-10-29 18:56:44
Traffic VEHICLE ACCIDENT - 2016-10-29 18:56:44
Traffic VEHICLE ACCIDENT - 2016-10-29 19:01:12
Traffic VEHICLE ACCIDENT - 2016-10-29 19:01:12
EMS HEMORRHAGING 2016-10-29 19:07:09
Traffic VEHICLE ACCIDENT - 2016-10-29 19:07:10
EMS ABDOMINAL PAINS 2016-10-29 19:11:35
EMS FALL VICTIM 2016-10-29 19:11:35
Traffic DISABLED VEHICLE - 2016-10-29 19:11:36
EMS VEHICLE ACCIDENT 2016-10-29 19:17:19
Fire FIRE ALARM 2016-10-29 19:17:19
Fire VEHICLE ACCIDENT 2016-10-29 19:17:19
Traffic DISABLED VEHICLE - 2016-10-29 19:17:20
Traffic DISABLED VEHICLE - 2016-10-29 19:17:20
Traffic VEHICLE ACCIDENT - 2016-10-29 19:17:20
Traffic DISABLED VEHICLE - 2016-10-29 19:17:21
EMS ALTERED MENTAL STATUS 2016-10-29 19:21:38
EMS SEIZURES 2016-10-29 19:27:22
Fire ELECTRICAL FIRE OUTSIDE 2016-10-29 19:31:40
Traffic DISABLED VEHICLE - 2016-10-29 19:31:41
EMS HEAD INJURY 2016-10-29 19:37:24
Traffic VEHICLE ACCIDENT - 2016-10-29 19:37:25
Fire FIRE INVESTIGATION 2016-10-29 19:46:00
EMS SYNCOPAL EPISODE 2016-10-29 19:47:27
EMS FALL VICTIM 2016-10-29 19:56:34
Traffic ROAD OBSTRUCTION - 2016-10-29 19:56:34
Traffic ROAD OBSTRUCTION - 2016-10-29 19:56:34
Traffic VEHICLE ACCIDENT - 2016-10-29 19:56:35
EMS CARDIAC EMERGENCY 2016-10-29 20:01:02
Traffic VEHICLE ACCIDENT - 2016-10-29 20:01:02
EMS SUBJECT IN PAIN 2016-10-29 20:06:49
EMS HEAD INJURY 2016-10-29 20:11:10
EMS HEMORRHAGING 2016-10-29 20:11:10
Fire VEHICLE ACCIDENT 2016-10-29 20:11:10
EMS VEHICLE ACCIDENT 2016-10-29 20:11:11
EMS HEAD INJURY 2016-10-29 20:11:12
Traffic VEHICLE ACCIDENT - 2016-10-29 20:11:12
EMS SHOOTING 2016-10-29 20:21:18
EMS BACK PAINS/INJURY 2016-10-29 20:26:53
Fire S/B AT HELICOPTER LANDING 2016-10-29 20:26:53
EMS S/B AT HELICOPTER LANDING 2016-10-29 20:26:54
Traffic DISABLED VEHICLE - 2016-10-29 20:26:55
Fire FIRE ALARM 2016-10-29 20:36:30
Traffic VEHICLE ACCIDENT - 2016-10-29 20:36:31
Fire VEHICLE ACCIDENT 2016-10-29 20:42:03
EMS VEHICLE ACCIDENT 2016-10-29 20:42:04
Traffic VEHICLE ACCIDENT - 2016-10-29 20:42:05
Traffic DISABLED VEHICLE - 2016-10-29 20:46:16
Traffic DISABLED VEHICLE - 2016-10-29 20:51:55
EMS ABDOMINAL PAINS 2016-10-29 20:56:05
Traffic VEHICLE ACCIDENT - 2016-10-29 20:56:06
Traffic VEHICLE ACCIDENT - 2016-10-29 21:01:42
Traffic DISABLED VEHICLE - 2016-10-29 21:07:17
Traffic DISABLED VEHICLE - 2016-10-29 21:07:17
EMS SUBJECT IN PAIN 2016-10-29 21:11:29
Fire UNKNOWN TYPE FIRE 2016-10-29 21:17:05
EMS SEIZURES 2016-10-29 21:21:17
Traffic VEHICLE ACCIDENT - 2016-10-29 21:21:17
Traffic VEHICLE ACCIDENT - 2016-10-29 21:26:54
Fire CARBON MONOXIDE DETECTOR 2016-10-29 21:31:05
EMS CVA/STROKE 2016-10-29 21:31:06
EMS UNKNOWN MEDICAL EMERGENCY 2016-10-29 21:31:06
EMS RESPIRATORY EMERGENCY 2016-10-29 21:36:39
Traffic DISABLED VEHICLE - 2016-10-29 21:36:40
Fire FIRE ALARM 2016-10-29 21:46:25
EMS CARDIAC EMERGENCY 2016-10-29 21:52:01
Fire VEHICLE FIRE 2016-10-29 21:52:01
EMS SUBJECT IN PAIN 2016-10-29 21:52:02
EMS VEHICLE ACCIDENT 2016-10-29 21:52:02
Traffic VEHICLE ACCIDENT - 2016-10-29 21:52:03
Traffic ROAD OBSTRUCTION - 2016-10-29 22:05:59
EMS BACK PAINS/INJURY 2016-10-29 22:11:47
EMS SYNCOPAL EPISODE 2016-10-29 22:11:48
EMS CARDIAC ARREST 2016-10-29 22:22:05
EMS CARDIAC EMERGENCY 2016-10-29 22:22:05
EMS OVERDOSE 2016-10-29 22:22:05
Fire CARDIAC ARREST 2016-10-29 22:26:30
EMS ASSAULT VICTIM 2016-10-29 22:32:22
Fire FIRE SPECIAL SERVICE 2016-10-29 22:36:46
Traffic VEHICLE ACCIDENT - 2016-10-29 22:47:02
Traffic VEHICLE ACCIDENT - 2016-10-29 22:47:02
Traffic DISABLED VEHICLE - 2016-10-29 22:51:23
Traffic DISABLED VEHICLE - 2016-10-29 23:06:01
EMS HEMORRHAGING 2016-10-29 23:07:29
Fire FIRE ALARM 2016-10-29 23:07:29
Fire FIRE ALARM 2016-10-29 23:11:53
Traffic DISABLED VEHICLE - 2016-10-29 23:11:54
Fire FIRE INVESTIGATION 2016-10-29 23:22:14
Fire FIRE ALARM 2016-10-29 23:31:04
EMS FALL VICTIM 2016-10-29 23:31:05
Traffic HAZARDOUS ROAD CONDITIONS - 2016-10-29 23:31:05
Traffic HAZARDOUS ROAD CONDITIONS - 2016-10-29 23:36:33
EMS VEHICLE ACCIDENT 2016-10-29 23:41:32
EMS OVERDOSE 2016-10-29 23:41:33
Traffic VEHICLE ACCIDENT - 2016-10-29 23:41:33
Traffic VEHICLE ACCIDENT - 2016-10-29 23:46:03
EMS FALL VICTIM 2016-10-29 23:51:22

¿Cómo funciona el programa?

Los códigos realizados para este proyecto de aula estan implementados en python y utilizan los siguientes paquetes:

  • Requests
  • Beautifulsoup4
  • Webbrowser
  • numpy
  • Ipython

descarga.py

Este archivo es el encargado de la extracción web de la base de datos que se descargará como archivo de texto plano con el nombre de tzr.csv.

Este código ingresa a la página http://montcoalert.org/gettingdata/ que es nuestra fuente de datos y busca la url del archivo tzr.csv que esta nos facilita y lo descarga en el directorio Codigo.

consulta.py

Este archivo contiene dos funciones:

  • Datos_necesarios():Carga el archivo de texto a una matriz y luego selecciona las columnas de los datos con mas relevancia en este caso y lo carga a la matriz donde se realiza la consulta.
  • Consulta():Solicita al usuario que ingrese el tipo de dato y el dato de búsqueda,luego llama a la función Datos_necesarios() que se encarga de buscar las coincidencias del dato ingresado en la matriz. Inmediatamente después genera una tabla markdown con los resultados de la búsqueda.

Estadistica-Analisis de Datos

Despúes de realizar la instalacion,inicializacion indicadas anteriormente(si no esta en el directorio Codigo dirigase a el) y ejecute GenArEst.py como se muestra a continuación.


In [5]:
%%bash 
python GenArEst.py

El codigo contenido en GenArEst.py lo que hara es generar una serie de archivos- necesarios para las estadisticas descriptiva e inferencial.

Estadistica:

Se tomo un conjunto de datos de interes para realizar estadistica basica con r(media,max,min,desviacion estandar)tanto por dias como por meses:


In [2]:
%%bash 
Rscript Estadistica.R #Estes archivo contiene el codigo que genera la estadistica y las imagenes.


[1] "--------------------------------------------------------------------------------------------"
[1] "En este archivo se realiza la Estadistica Descriptiva de los diferentes variables y resumenes"
[1] "--------------------------------------------------------------------------------------------"
[1] "--Resumen de frecuencia de datos--"
     title                      description            Date       
 EMS    :63327   VEHICLE ACCIDENT -   :30230   2016-01-23:   913  
 Fire   :19403   DISABLED VEHICLE -   : 9786   2016-02-24:   679  
 Traffic:46193   VEHICLE ACCIDENT     : 7354   2016-01-24:   662  
                 FIRE ALARM           : 7302   2016-01-12:   588  
                 RESPIRATORY EMERGENCY: 6482   2016-04-03:   586  
                 CARDIAC EMERGENCY    : 6418   2016-07-25:   580  
                 (Other)              :61351   (Other)   :124915  
       Hour               Day            Month      
 16:47:01:   288   Friday   :19762   Jan    :13205  
 16:22:01:   284   Monday   :18753   Oct    :12555  
 15:42:01:   283   Saturday :17380   Jul    :12137  
 16:17:01:   281   Sunday   :15789   Aug    :11965  
 17:22:01:   281   Thursday :19027   Jun    :11786  
 17:42:01:   273   Tuesday  :19018   Sep    :11720  
 (Other) :127233   Wednesday:19194   (Other):55555  

   Friday    Monday  Saturday    Sunday  Thursday   Tuesday Wednesday 
    19762     18753     17380     15789     19027     19018     19194 
[1] 18417.57
[1] "Dia en el que mas se presentan las llamadas"
[1] "Friday"
[1] "A continuacion se muestran algunos datos estadisticas  de las llamadas por mes"
[1] "Mes con mas numero de emergencias registradas"
[1] "Jan"
[1] "Media de las llamadas por mes "
[1] 10743.58
[1] "Maximo "
[1] 13205
[1] "Minimo"
[1] 2269
[1] "Desviacion estandar"
[1] 2950.841
null device 
          1 
[1] "Resumen de llamadas por dia"
Number of cases in table: 128923 
Number of factors: 1 
null device 
          1 
[1] "Dia en el que mas se presentan las llamadas"
[1] "Friday"
[1] "Media de las llamadas por dia"
[1] 383.6994
[1] "Maximo "
[1] 411.7083
[1] "Minimo"
[1] 328.9375
[1] "Desviacion estandar"
[1] 28.51543
[1] "Resumen de llamadas semanales"
Number of cases in table: 2685.896 
Number of factors: 1 
null device 
          1 
[1] "Tipo de emergencia donde se presentan mas llamadas semanales"
[1] "EMS"
[1] "Media de las llamadas semanales "
[1] 895.2986
[1] "Maximo "
[1] 1319.312
[1] "Minimo"
[1] 404.2292
[1] "Desviacion estandar"
[1] 461.2122
[1] "Resumen de llamadas al dia"
Number of cases in table: 383.6994 
Number of factors: 1 
null device 
          1 
[1] "Tipo de emergencia donde se presentan mas llamadas al dia"
[1] "EMS"
[1] "Media de las llamadas por dia "
[1] 127.8998
[1] "Maximo "
[1] 188.4732
[1] "Minimo"
[1] 57.74702
[1] "Desviacion estandar"
[1] 65.88746
[1] "Resumen de llamadas al dia"
    Trafico             Dia      
 Traffic:46193   Friday   :7361  
                 Monday   :6714  
                 Saturday :5950  
                 Sunday   :4645  
                 Thursday :7101  
                 Tuesday  :7186  
                 Wednesday:7236  
null device 
          1 
[1] "Dia en que se presentan mas emergencias de trafico"
[1] "Friday"
[1] "Media de las llamadas relacionadas al trafico al dia "
[1] 137.4792
[1] "Maximo "
[1] 153.3542
[1] "Minimo"
[1] 96.77083
[1] "Desviacion estandar"
[1] 20.54581
[1] "Resumen de llamadas por  victimas(Fall victim)por mes "
         Victim         Month     
 FALL VICTIM:6332   Jan    : 669  
                    Oct    : 646  
                    Jul    : 630  
                    May    : 585  
                    Aug    : 572  
                    Jun    : 569  
                    (Other):2661  
null device 
          1 
[1] "Mes en donde se prensentan mas vitimas fatales"
[1] "Jan"
[1] "Media de las llamadas relacionadas a victimas fatales "
[1] 527.6667
[1] "Maximo "
[1] 669
[1] "Minimo"
[1] 104
[1] "Desviacion estandar"
[1] 151.1215
[1] "Resumen de llamadas por reacciones alergicas por mes"
              Allergic       Month    
 ALLERGIC REACTION:565   Aug    : 85  
                         Jul    : 62  
                         Jun    : 56  
                         Oct    : 50  
                         Apr    : 47  
                         May    : 47  
                         (Other):218  
null device 
          1 
[1] "Mes en donde se prensentan mas casos de alergias"
[1] "Aug"
[1] "Media de las llamadas relacionadas a casos de alergias "
[1] 47.08333
[1] "Maximo "
[1] 85
[1] "Minimo"
[1] 8
[1] "Desviacion estandar"
[1] 17.78896
[1] "¿Es Cierto que Diciembre es el mes con mayor numero de Emergencias?"
[1] "Falso"

Estadistica Descriptiva

-Ejemplos-

Promedio de llamadas de cada mes:

Promedio de llamadas por reacciones alergias por mes:

Promedio de llamadas por victimas fatales por mes:

Promedio de Accidentes de trafico al dia

Estadistica Inferencial

-ejemplos-

Probabilidad de llamadas relacionadas a Fuego

Probabilidad de llamadas relacionadas a Trafico

Probabilidad de llamadas relacionadas a EMS