Motor Vehicle Fatal Crashes by Time and Day and Weather Conditions

JohnSnowLabs

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

Data Files

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

motor-vehicle-fatal-crashes-by-time-and-day-and-weather-conditions_zip  

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

Read me

Import into your tool

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

install.packages("jsonlite")
library("jsonlite")

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

# access csv file by the index starting from 1
path_to_file = json_data$resources$path[1][1]
data <- read.csv(url(path_to_file))
print(data)

In order to work with Data Packages in Pandas you need to install the Frictionless Data data package library and the pandas extension:

pip install datapackage
pip install jsontableschema-pandas

To get the data run following code:

import datapackage

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

# to load Data Package into storage
storage = datapackage.push_datapackage(data_url, 'pandas')

# data frames available (corresponding to data files in original dataset)
storage.buckets

# you can access datasets inside storage, e.g. the first one:
storage[storage.buckets[0]]

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('http://datahub.io/JohnSnowLabs/motor-vehicle-fatal-crashes-by-time-and-day-and-weather-conditions/datapackage.json')

# get list of resources:
resources = package.descriptor['resources']
resourceList = [resources[x]['name'] for x in range(0, len(resources))]
print(resourceList)

data = package.resources[0].read()
print(data)

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 = 'http://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 the first data file in this dataset
  const file = dataset.resources[0]
  // Get a raw stream
  const stream = await file.stream()
  // entire file as a buffer (be careful with large files!)
  const buffer = await file.buffer
})()

Install the datapackage library created specially for Ruby language using gem:

gem install datapackage

Now get the dataset and read the data:

require 'datapackage'

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

package = DataPackage::Package.new(path)
# So package variable contains metadata. You can see it:
puts package

# Read data itself:
resource = package.resources[0]
data = resource.read
puts data
Datapackage.json