Motor Vehicle Fatal Crashes by Time and Day and Weather Conditions

JohnSnowLabs

Files Size Format Created Updated License Source
2 99kB csv zip 3 months ago John Snow Labs Standard License John Snow Labs Bureau of Transportation Statistics
Download

Data Files

File Description Size Last changed Download
motor-vehicle-fatal-crashes-by-time-and-day-and-weather-conditions-csv 4kB csv (4kB) , json (32kB)
motor-vehicle-fatal-crashes-by-time-and-day-and-weather-conditions_zip Compressed versions of dataset. Includes normalized CSV and JSON data with original data and datapackage.json. 9kB zip (9kB)

motor-vehicle-fatal-crashes-by-time-and-day-and-weather-conditions-csv  

This is a preview version. There might be more data in the original version.

Field information

Field Name Order Type (Format) Description
Year 1 date (%Y-%m-%d) Year of data
Total_Fatal_Crashes 2 integer Total number of fatal motor crashes
Total_Fatal_Crashes_On_Sunday 3 number Total number of fatal motor crashes on Sunday
Total_Fatal_Crashes_On_Monday 4 number Total number of fatal motor crashes on Monday
Total_Fatal_Crashes_On_Tuesday 5 number Total number of fatal motor crashes on Tuesday
Total_Fatal_Crashes_On_Wednesday 6 number Total number of fatal motor crashes on Wednesday
Total_Fatal_Crashes_On_Thursday 7 number Total number of fatal motor crashes on Thursday
Total_Fatal_Crashes_On_Friday 8 number Total number of fatal motor crashes on Friday
Total_Fatal_Crashes_On_Saturday 9 number Total number of fatal motor crashes on Saturday
Total_Fatal_Crashes_On_Unknown_Day_Of_Week 10 number Total number of fatal motor crashes where day of week is unknown
Total_Fatal_Crashes_at_Midnight_To_3am 11 number Total number of fatal motor crashes at midnight to 3am
Total_Fatal_Crashes_at_3am_To_6am 12 number Total number of fatal motor crashes at 3am to 6am
Total_Fatal_Crashes_at_6am_To_9am 13 number Total number of fatal motor crashes at 6am to 9am
Total_Fatal_Crashes_at_9am_To_Noon 14 number Total number of fatal motor crashes at 9am to noon
Total_Fatal_Crashes_at_Noon_To_3pm 15 number Total number of fatal motor crashes at noon to 3pm
Total_Fatal_Crashes_at_3pm_To_6pm 16 number Total number of fatal motor crashes at 3pm to 6pm
Total_Fatal_Crashes_at_6pm_To_9pm 17 number Total number of fatal motor crashes at 6pm to 9pm
Total_Fatal_Crashes_at_9pm_To_Midnight 18 number Total number of fatal motor crashes at 9pm to midnight
Total_Fatal_Crashes_at_Unknown_Time_Of_Day 19 number Total number of fatal motor crashes where time of day is unknown
Total_Fatal_Crashes_On_Atmospheric_Condition_Normal 20 number Total number of fatal motor crashes when Atmospheric condition is normal
Total_Fatal_Crashes_On_Atmospheric_Condition_Rainy 21 number Total number of fatal motor crashes when Atmospheric condition is rainy
Total_Fatal_Crashes_On_Atmospheric_Condition_Snowy 22 number Total number of fatal motor crashes when Atmospheric condition is snowy
Total_Fatal_Crashes_On_Atmospheric_Condition_Other_Or_Unknown 23 number Total number of fatal motor crashes when Atmospheric conditions are unknown
Total_Fatal_Crashes_On_Daylight_Condition 24 number Total number of fatal motor crashes on light conditions when daylight is present
Total_Fatal_Crashes_On_Dark_But_Lighted_Condition 25 number Total number of fatal motor crashes on light conditions when it is dark but lighted
Total_Fatal_Crashes_On_Light_Condition_Dark 26 number Total number of fatal motor crashes on light conditions when it is dark
Total_Fatal_Crashes_On_Light_Condition_Dawn_Or_Dusk 27 number Total number of fatal motor crashes on light conditions when it is dawn or dusk
Total_Fatal_Crashes_On_Unknown_Light_Condition 28 number Total number of fatal motor crashes when light conditions are unknown

Import into your tool

Data-cli or just data is the program to get and post your data with the datahub.
Use data with the datahub.io almost like you use git with the github. Here are installation instructions.

data get https://datahub.io/JohnSnowLabs/motor-vehicle-fatal-crashes-by-time-and-day-and-weather-conditions
tree JohnSnowLabs/motor-vehicle-fatal-crashes-by-time-and-day-and-weather-conditions
# Get a list of dataset's resources
curl -L -s https://datahub.io/JohnSnowLabs/motor-vehicle-fatal-crashes-by-time-and-day-and-weather-conditions/datapackage.json | grep path

# Get resources

curl -L https://datahub.io/JohnSnowLabs/motor-vehicle-fatal-crashes-by-time-and-day-and-weather-conditions/r/0.csv

curl -L https://datahub.io/JohnSnowLabs/motor-vehicle-fatal-crashes-by-time-and-day-and-weather-conditions/r/1.zip

If you are using R here's how to get the data you want quickly loaded:

install.packages("jsonlite", repos="https://cran.rstudio.com/")
library("jsonlite")

json_file <- 'https://datahub.io/JohnSnowLabs/motor-vehicle-fatal-crashes-by-time-and-day-and-weather-conditions/datapackage.json'
json_data <- fromJSON(paste(readLines(json_file), collapse=""))

# get list of all resources:
print(json_data$resources$name)

# print all tabular data(if exists any)
for(i in 1:length(json_data$resources$datahub$type)){
  if(json_data$resources$datahub$type[i]=='derived/csv'){
    path_to_file = json_data$resources$path[i]
    data <- read.csv(url(path_to_file))
    print(data)
  }
}

Note: You might need to run the script with root permissions if you are running on Linux machine

Install the Frictionless Data data package library and the pandas itself:

pip install datapackage
pip install pandas

Now you can use the datapackage in the Pandas:

import datapackage
import pandas as pd

data_url = 'https://datahub.io/JohnSnowLabs/motor-vehicle-fatal-crashes-by-time-and-day-and-weather-conditions/datapackage.json'

# to load Data Package into storage
package = datapackage.Package(data_url)

# to load only tabular data
resources = package.resources
for resource in resources:
    if resource.tabular:
        data = pd.read_csv(resource.descriptor['path'])
        print (data)

For Python, first install the `datapackage` library (all the datasets on DataHub are Data Packages):

pip install datapackage

To get Data Package into your Python environment, run following code:

from datapackage import Package

package = Package('https://datahub.io/JohnSnowLabs/motor-vehicle-fatal-crashes-by-time-and-day-and-weather-conditions/datapackage.json')

# print list of all resources:
print(package.resource_names)

# print processed tabular data (if exists any)
for resource in package.resources:
    if resource.descriptor['datahub']['type'] == 'derived/csv':
        print(resource.read())

If you are using JavaScript, please, follow instructions below:

Install data.js module using npm:

  $ npm install data.js

Once the package is installed, use the following code snippet:

const {Dataset} = require('data.js')

const path = 'https://datahub.io/JohnSnowLabs/motor-vehicle-fatal-crashes-by-time-and-day-and-weather-conditions/datapackage.json'

// We're using self-invoking function here as we want to use async-await syntax:
;(async () => {
  const dataset = await Dataset.load(path)
  // get list of all resources:
  for (const id in dataset.resources) {
    console.log(dataset.resources[id]._descriptor.name)
  }
  // get all tabular data(if exists any)
  for (const id in dataset.resources) {
    if (dataset.resources[id]._descriptor.format === "csv") {
      const file = dataset.resources[id]
      // Get a raw stream
      const stream = await file.stream()
      // entire file as a buffer (be careful with large files!)
      const buffer = await file.buffer
      // print data
      stream.pipe(process.stdout)
    }
  }
})()
Datapackage.json