Amazon Last Mile Dataset
An example of how we use a Python dictionary in a real-world scenario.
Source: https://registry.opendata.aws/amazon-last-mile-challenges/
Challenge:
find the volume of one package in the dataset
Let's explore the dataset
# Python program to read json file
import json
# Opening JSON file
f = open('new_package_data.json')
# returns JSON object as a dictionary
data = json.load(f)
# Closing file
f.close()
Run to view results
data.keys()
Run to view results
data['RouteID_15baae2d-bf07-4967-956a-173d4036613f']
Run to view results
data['RouteID_15baae2d-bf07-4967-956a-173d4036613f']['AU']
Run to view results
data['RouteID_15baae2d-bf07-4967-956a-173d4036613f']['AU']['PackageID_180d6ed8-e08c-4a2a-972c-b0d6f1bd68ed']
Run to view results
data['RouteID_15baae2d-bf07-4967-956a-173d4036613f']['AU']['PackageID_180d6ed8-e08c-4a2a-972c-b0d6f1bd68ed']['dimensions']
Run to view results
d = data['RouteID_15baae2d-bf07-4967-956a-173d4036613f']['AU']['PackageID_180d6ed8-e08c-4a2a-972c-b0d6f1bd68ed']['dimensions']['depth_cm']
print(d)
Run to view results
h = data['RouteID_15baae2d-bf07-4967-956a-173d4036613f']['AU']['PackageID_180d6ed8-e08c-4a2a-972c-b0d6f1bd68ed']['dimensions']['height_cm']
print(h)
Run to view results
w = data['RouteID_15baae2d-bf07-4967-956a-173d4036613f']['AU']['PackageID_180d6ed8-e08c-4a2a-972c-b0d6f1bd68ed']['dimensions']['width_cm']
print(w)
Run to view results
print('A package has dimensions of %s cubic centemeters' %(d*w*h))
Run to view results