0% found this document useful (0 votes)
9 views11 pages

02 Python Alt Data NLP Class Example

The document outlines a method for converting images of car counts from a parking lot into a structured time series for analysis. It details the use of Python libraries such as OpenCV and cvlib to detect cars in images, draw bounding boxes, and extract relevant data. The process includes parsing image filenames to create a dictionary that associates timestamps with car counts for further analysis.

Uploaded by

Karry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views11 pages

02 Python Alt Data NLP Class Example

The document outlines a method for converting images of car counts from a parking lot into a structured time series for analysis. It details the use of Python libraries such as OpenCV and cvlib to detect cars in images, draw bounding boxes, and extract relevant data. The process includes parsing image filenames to create a dictionary that associates timestamps with car counts for further analysis.

Uploaded by

Karry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Example from Introduction to alternative data

Saeed Amen / Founder of Cuemacro

https://www.cuemacro.com / saeed@cuemacro.com / @saeedamenfx / All material is copyright Cuemacro /


2020

In the course notes, we showed that we can use a time series of car counts for European retailers to understand
earnings per share statistics for these firms. In practice, how do we go about convert images of cars in a parking
lot on different days into such a time series? In other words, how do we structure the image data from an
unstructured form.

In this class example, we shall show you how to convert images of car counts collected a different times of the
same car park into a time series which can be more easily processed.

Creating a car count time series


Download carcount.zip from the Google Drive and extract in a folder raw_data/car_count underneath where
this notebook is located. We have used a subset of images collected by https://cnrpark.it/. We'll only look at
images from one particular camera angle camera1 , however the original dataset contains 9 cameras.

Define the raw_data_path variable to be equal to the folder where

In [1]: # Uncomment the below


# raw_data_path = 'raw_data/car_count/'

Import IOpenCV cv2 . We also import the higher level cvlib library, which has convenient methods to
detect_common_objects and also draw bounding boxes for detected objects on images draw_bbox .

In [2]: # Imports for cv2 and cvlib libraries

We write a function car_count_from_image which takes in a image filename and outputs the number of
car or truck objects in the image, alongside the binary image representation, the coordinates of each object
bounding box, the labels of those objects and finally the confidence of the classification.

In [3]: # Read the image from disk (Hint: use imread in cv2)

# Hint: use `detect_common_objects` from cvlib

Using the image filename OVERCAST/2015-11-16/camera1/2015-11-16_0840.jpg , we run


car_count_from_image on it. We then print out the car_count which is returned. In this case it's 17.

In [4]:

17
Is the detection of cars any good? Let's write a new function write_image_object_bounded_box which takes
as an input the filename of the car park image we would to run the car count algorithm on. The function then
draws boundary boxes on the detected objects and then writes it back to disk.

In [5]: # Read the image into memory


# Detect common objects, outputting the boundary box, label and confidence

# Draw bounding boxes on top of our source image


# for detected objects

# Write a new image to disk with the boundary boxes

Let's try out our function for drawing the detected objects on our original image. Also display the modified
image back to the user. We see that the output is pretty good. It's detected most of the cars. Admittedly, it has
trouble for those cars which are obscured by trees. It is likely that from other camera angles, these cars wouldn't
be obscured. However, for simplicity we are just looking at one angle.

In [6]:

Out[6]:

We've now written functions for using cvlib and cv2 to detect cars (and trucks) from a particular image. The
next step is to create a list of all the car park images in our folder and sort that

In [7]: # Create an empty list

# Go through all the root, directories underneath and then the files
# In a double nested for loop
# Hint: use os.walk
# Append the file name to the list

# Sort list alphabetically


Go through every image on the filepath, and then perform a car count using car_count_from_image . We'll
create a Python dictionary with the keys of the image snapshot, and values as the actual car counts.

Each filename is in the form eg. 2015-11-16_0710.jpg so we can identify the date and time of the car count
image.

In [8]: # Go through each image in the list of paths


# Call car_count_from_image, to get the car_count for that image
# We'll ignore all the other outputs of that function

# Get the filename (excluding .jpg)


# Hint: use os.path.basename to extract the filename from the path
# Eg. from raw_data/car_count/OVERCAST/2015-11-16/camera1/2015-11-16_0710.jpg
# get 2015-11-16_0710

# Now parse the filename into a Python date


# eg. 2015-11-16_0710 => 2015-11-16 07:10 etc.

# Assign the datetime key in the dictionary to equal car_count

Parsing... 2015-11-16 07:10:00


Parsing... 2015-11-16 07:40:00
Parsing... 2015-11-16 08:10:00
Parsing... 2015-11-16 08:40:00
Parsing... 2015-11-16 09:10:00
Parsing... 2015-11-16 09:40:00
Parsing... 2015-11-16 10:10:00
Parsing... 2015-11-16 10:40:00
Parsing... 2015-11-16 11:10:00
Parsing... 2015-11-16 11:40:00
Parsing... 2015-11-16 12:10:00
Parsing... 2015-11-16 12:40:00
Parsing... 2015-11-16 13:10:00
Parsing... 2015-11-16 13:40:00
Parsing... 2015-11-16 14:10:00
Parsing... 2015-11-16 14:40:00
Parsing... 2015-11-16 15:10:00
Parsing... 2015-11-16 15:40:00
Parsing... 2015-11-16 16:10:00
Parsing... 2015-11-16 16:40:00
Parsing... 2015-11-16 17:10:00
Parsing... 2015-11-20 07:10:00
Parsing... 2015-11-20 07:40:00
Parsing... 2015-11-20 08:10:00
Parsing... 2015-11-20 08:40:00
Parsing... 2015-11-20 09:10:00
Parsing... 2015-11-20 09:40:00
Parsing... 2015-11-20 10:10:00
Parsing... 2015-11-20 10:40:00
Parsing... 2015-11-20 11:10:00
Parsing... 2015-11-20 11:40:00
Parsing... 2015-11-20 12:10:00
Parsing... 2015-11-20 12:40:00
Parsing... 2015-11-20 13:10:00
Parsing... 2015-11-20 13:40:00
Parsing... 2015-11-20 14:10:00
Parsing... 2015-11-20 14:40:00
Parsing... 2015-11-20 15:10:00
Parsing... 2015-11-20 15:40:00
Parsing... 2015-11-20 16:10:00
Parsing... 2015-11-20 16:40:00
Parsing... 2015-11-25 07:10:00
Parsing... 2015-11-25 07:40:00
Parsing... 2015-11-25 08:10:00
Parsing... 2015-11-25 08:40:00
Parsing... 2015-11-25 09:10:00
Parsing... 2015-11-25 09:40:00
Parsing... 2015-11-25 10:10:00
Parsing... 2015-11-25 10:40:00
Parsing... 2015-11-25 11:10:00
Parsing... 2015-11-25 11:40:00
Parsing... 2015-11-25 12:10:00
Parsing... 2015-11-25 12:40:00
Parsing... 2015-11-25 13:10:00
Parsing... 2015-11-25 13:40:00
Parsing... 2015-11-25 14:10:00
Parsing... 2015-11-25 14:40:00
Parsing... 2015-11-25 15:10:00
Parsing... 2015-11-25 15:40:00
Parsing... 2015-11-25 16:10:00
Parsing... 2015-11-25 16:40:00
Parsing... 2015-11-29 07:40:00
Parsing... 2015-11-29 08:10:00
Parsing... 2015-11-29 08:40:00
Parsing... 2015-11-29 09:10:00
Parsing... 2015-11-29 09:40:00
Parsing... 2015-11-29 10:10:00
Parsing... 2015-11-29 10:40:00
Parsing... 2015-11-29 11:10:00
Parsing... 2015-11-29 11:40:00
Parsing... 2015-11-29 12:10:00
Parsing... 2015-11-29 12:40:00
Parsing... 2015-11-29 13:10:00
Parsing... 2015-11-29 13:40:00
Parsing... 2015-11-29 14:10:00
Parsing... 2015-11-29 14:40:00
Parsing... 2015-11-29 15:10:00
Parsing... 2015-11-29 15:40:00
Parsing... 2015-11-29 16:10:00
Parsing... 2015-11-29 16:40:00
Parsing... 2015-12-03 07:41:00
Parsing... 2015-12-03 08:11:00
Parsing... 2015-12-03 08:41:00
Parsing... 2015-12-03 09:11:00
Parsing... 2015-12-03 09:41:00
Parsing... 2015-12-03 10:11:00
Parsing... 2015-12-03 10:41:00
Parsing... 2015-12-03 11:11:00
Parsing... 2015-12-03 11:41:00
Parsing... 2015-12-03 12:11:00
Parsing... 2015-12-03 12:41:00
Parsing... 2015-12-03 13:11:00
Parsing... 2015-12-03 13:41:00
Parsing... 2015-12-03 14:11:00
Parsing... 2015-12-03 14:41:00
Parsing... 2015-12-03 15:11:00
Parsing... 2015-12-03 15:41:00
Parsing... 2015-12-03 16:11:00
Parsing... 2015-12-03 16:41:00
Parsing... 2015-12-18 07:48:00
Parsing... 2015-12-18 08:18:00
Parsing... 2015-12-18 08:48:00
Parsing... 2015-12-18 09:18:00
Parsing... 2015-12-18 09:48:00
Parsing... 2015-12-18 10:18:00
Parsing... 2015-12-18 10:48:00
Parsing... 2015-12-18 11:18:00
Parsing... 2015-12-18 11:48:00
Parsing... 2015-12-18 12:18:00
Parsing... 2015-12-18 12:48:00
Parsing... 2015-12-18 13:18:00
Parsing... 2015-12-18 13:48:00
Parsing... 2015-12-18 14:18:00
Parsing... 2015-12-18 14:48:00
Parsing... 2015-12-18 15:18:00
Parsing... 2015-12-18 15:48:00
Parsing... 2015-12-18 16:18:00
Parsing... 2015-12-18 16:48:00
Parsing... 2015-12-19 07:48:00
Parsing... 2015-12-19 08:18:00
Parsing... 2015-12-19 08:48:00
Parsing... 2015-12-19 09:18:00
Parsing... 2015-12-19 09:48:00
Parsing... 2015-12-19 10:18:00
Parsing... 2015-12-19 10:48:00
Parsing... 2015-12-19 11:18:00
Parsing... 2015-12-19 11:48:00
Parsing... 2015-12-19 12:18:00
Parsing... 2015-12-19 12:48:00
Parsing... 2015-12-19 13:18:00
Parsing... 2015-12-19 13:48:00
Parsing... 2015-12-19 14:18:00
Parsing... 2015-12-19 14:48:00
Parsing... 2015-12-19 15:18:00
Parsing... 2015-12-19 15:48:00
Parsing... 2015-12-19 16:18:00
Parsing... 2015-12-19 16:48:00
Parsing... 2015-11-21 07:40:00
Parsing... 2015-11-21 08:10:00
Parsing... 2015-11-21 08:40:00
Parsing... 2015-11-21 09:10:00
Parsing... 2015-11-21 09:40:00
Parsing... 2015-11-21 10:10:00
Parsing... 2015-11-21 10:40:00
Parsing... 2015-11-21 11:10:00
Parsing... 2015-11-21 11:40:00
Parsing... 2015-11-21 12:10:00
Parsing... 2015-11-21 12:40:00
Parsing... 2015-11-21 13:10:00
Parsing... 2015-11-21 13:40:00
Parsing... 2015-11-21 14:10:00
Parsing... 2015-11-21 14:40:00
Parsing... 2015-11-21 15:10:00
Parsing... 2015-11-21 15:40:00
Parsing... 2015-11-21 16:10:00
Parsing... 2015-11-21 16:40:00
Parsing... 2015-12-22 07:48:00
Parsing... 2015-12-22 08:18:00
Parsing... 2015-12-22 08:48:00
Parsing... 2015-12-22 09:18:00
Parsing... 2015-12-22 09:48:00
Parsing... 2015-12-22 10:18:00
Parsing... 2015-12-22 10:48:00
Parsing... 2015-12-22 11:18:00
Parsing... 2015-12-22 11:48:00
Parsing... 2015-12-22 12:18:00
Parsing... 2015-12-22 12:48:00
Parsing... 2015-12-22 13:18:00
Parsing... 2015-12-22 13:48:00
Parsing... 2015-12-22 14:18:00
Parsing... 2015-12-22 14:48:00
Parsing... 2015-12-22 15:18:00
Parsing... 2015-12-22 15:48:00
Parsing... 2015-12-22 16:18:00
Parsing... 2015-12-22 16:48:00
Parsing... 2016-01-08 07:19:00
Parsing... 2016-01-08 07:49:00
Parsing... 2016-01-08 08:19:00
Parsing... 2016-01-08 08:49:00
Parsing... 2016-01-08 09:19:00
Parsing... 2016-01-08 09:49:00
Parsing... 2016-01-08 10:19:00
Parsing... 2016-01-08 10:49:00
Parsing... 2016-01-08 11:19:00
Parsing... 2016-01-08 11:49:00
Parsing... 2016-01-08 12:19:00
Parsing... 2016-01-08 12:49:00
Parsing... 2016-01-08 13:19:00
Parsing... 2016-01-08 13:49:00
Parsing... 2016-01-08 14:19:00
Parsing... 2016-01-08 14:49:00
Parsing... 2016-01-08 15:19:00
Parsing... 2016-01-08 15:49:00
Parsing... 2016-01-08 16:19:00
Parsing... 2016-01-08 16:49:00
Parsing... 2016-01-08 17:19:00
Parsing... 2016-01-08 17:49:00
Parsing... 2016-01-09 07:19:00
Parsing... 2016-01-09 07:49:00
Parsing... 2016-01-09 08:19:00
Parsing... 2016-01-09 08:49:00
Parsing... 2016-01-09 09:19:00
Parsing... 2016-01-09 09:49:00
Parsing... 2016-01-09 10:19:00
Parsing... 2016-01-09 10:49:00
Parsing... 2016-01-09 11:19:00
Parsing... 2016-01-09 11:49:00
Parsing... 2016-01-09 12:19:00
Parsing... 2016-01-09 12:49:00
Parsing... 2016-01-09 13:19:00
Parsing... 2016-01-09 13:49:00
Parsing... 2016-01-09 14:19:00
Parsing... 2016-01-09 14:49:00
Parsing... 2016-01-09 15:19:00
Parsing... 2016-01-09 15:49:00
Parsing... 2016-01-09 16:19:00
Parsing... 2016-01-09 16:49:00
Parsing... 2016-01-09 17:19:00
Parsing... 2016-01-09 17:49:00
Parsing... 2016-01-14 08:05:00
Parsing... 2016-01-14 08:35:00
Parsing... 2016-01-14 09:05:00
Parsing... 2016-01-14 09:35:00
Parsing... 2016-01-14 10:05:00
Parsing... 2016-01-14 10:35:00
Parsing... 2016-01-14 11:05:00
Parsing... 2016-01-14 11:35:00
Parsing... 2016-01-14 12:05:00
Parsing... 2016-01-14 12:35:00
Parsing... 2016-01-14 13:05:00
Parsing... 2016-01-14 13:35:00
Parsing... 2016-01-14 14:05:00
Parsing... 2016-01-14 14:35:00
Parsing... 2016-01-14 15:05:00
Parsing... 2016-01-14 15:35:00
Parsing... 2016-01-14 16:05:00
Parsing... 2016-01-14 16:35:00
Parsing... 2016-01-14 17:05:00
Parsing... 2016-02-12 07:10:00
Parsing... 2016-02-12 07:40:00
Parsing... 2016-02-12 08:10:00
Parsing... 2016-02-12 08:40:00
Parsing... 2016-02-12 09:10:00
Parsing... 2016-02-12 09:40:00
Parsing... 2016-02-12 10:10:00
Parsing... 2016-02-12 10:40:00
Parsing... 2016-02-12 11:10:00
Parsing... 2016-02-12 11:40:00
Parsing... 2016-02-12 12:10:00
Parsing... 2016-02-12 12:40:00
Parsing... 2016-02-12 13:10:00
Parsing... 2016-02-12 13:40:00
Parsing... 2016-02-12 14:10:00
Parsing... 2016-02-12 14:40:00
Parsing... 2016-02-12 15:10:00
Parsing... 2016-02-12 15:40:00
Parsing... 2016-02-12 16:10:00
Parsing... 2016-02-12 16:40:00
Parsing... 2016-02-12 17:10:00
Parsing... 2016-02-12 17:40:00
Parsing... 2016-02-12 18:10:00
Parsing... 2015-11-12 07:09:00
Parsing... 2015-11-12 07:39:00
Parsing... 2015-11-12 08:09:00
Parsing... 2015-11-12 08:39:00
Parsing... 2015-11-12 09:09:00
Parsing... 2015-11-12 09:39:00
Parsing... 2015-11-12 10:09:00
Parsing... 2015-11-12 10:39:00
Parsing... 2015-11-12 11:09:00
Parsing... 2015-11-12 11:39:00
Parsing... 2015-11-12 12:09:00
Parsing... 2015-11-12 12:39:00
Parsing... 2015-11-12 13:09:00
Parsing... 2015-11-12 13:39:00
Parsing... 2015-11-12 14:09:00
Parsing... 2015-11-12 14:39:00
Parsing... 2015-11-12 15:09:00
Parsing... 2015-11-12 15:39:00
Parsing... 2015-11-12 16:09:00
Parsing... 2015-11-12 16:39:00
Parsing... 2015-11-12 17:09:00
Parsing... 2015-11-22 07:10:00
Parsing... 2015-11-22 07:40:00
Parsing... 2015-11-22 08:10:00
Parsing... 2015-11-22 08:40:00
Parsing... 2015-11-22 09:10:00
Parsing... 2015-11-22 09:40:00
Parsing... 2015-11-22 10:10:00
Parsing... 2015-11-22 10:40:00
Parsing... 2015-11-22 11:10:00
Parsing... 2015-11-22 11:40:00
Parsing... 2015-11-22 12:10:00
Parsing... 2015-11-22 12:40:00
Parsing... 2015-11-22 13:10:00
Parsing... 2015-11-22 13:40:00
Parsing... 2015-11-22 14:10:00
Parsing... 2015-11-22 14:40:00
Parsing... 2015-11-22 15:10:00
Parsing... 2015-11-22 15:40:00
Parsing... 2015-11-22 16:10:00
Parsing... 2015-11-22 16:40:00
Parsing... 2015-11-27 07:10:00
Parsing... 2015-11-27 07:40:00
Parsing... 2015-11-27 08:10:00
Parsing... 2015-11-27 08:40:00
Parsing... 2015-11-27 09:10:00
Parsing... 2015-11-27 09:40:00
Parsing... 2015-11-27 10:10:00
Parsing... 2015-11-27 10:40:00
Parsing... 2015-11-27 11:10:00
Parsing... 2015-11-27 11:40:00
Parsing... 2015-11-27 12:10:00
Parsing... 2015-11-27 12:40:00
Parsing... 2015-11-27 13:10:00
Parsing... 2015-11-27 13:40:00
Parsing... 2015-11-27 14:10:00
Parsing... 2015-11-27 14:40:00
Parsing... 2015-11-27 15:10:00
Parsing... 2015-11-27 15:40:00
Parsing... 2015-11-27 16:10:00
Parsing... 2015-11-27 16:40:00
Parsing... 2015-12-10 07:41:00
Parsing... 2015-12-10 08:11:00
Parsing... 2015-12-10 08:41:00
Parsing... 2015-12-10 09:11:00
Parsing... 2015-12-10 09:41:00
Parsing... 2015-12-10 10:11:00
Parsing... 2015-12-10 10:41:00
Parsing... 2015-12-10 11:11:00
Parsing... 2015-12-10 11:41:00
Parsing... 2015-12-10 12:11:00
Parsing... 2015-12-10 12:41:00
Parsing... 2015-12-10 13:11:00
Parsing... 2015-12-10 13:41:00
Parsing... 2015-12-10 14:11:00
Parsing... 2015-12-10 14:41:00
Parsing... 2015-12-10 15:12:00
Parsing... 2015-12-10 15:41:00
Parsing... 2015-12-10 16:11:00
Parsing... 2015-12-10 16:41:00
Parsing... 2015-12-17 07:48:00
Parsing... 2015-12-17 08:18:00
Parsing... 2015-12-17 08:48:00
Parsing... 2015-12-17 09:18:00
Parsing... 2015-12-17 09:48:00
Parsing... 2015-12-17 10:18:00
Parsing... 2015-12-17 10:48:00
Parsing... 2015-12-17 11:18:00
Parsing... 2015-12-17 11:48:00
Parsing... 2015-12-17 12:18:00
Parsing... 2015-12-17 12:48:00
Parsing... 2015-12-17 13:18:00
Parsing... 2015-12-17 13:48:00
Parsing... 2015-12-17 14:18:00
Parsing... 2015-12-17 14:48:00
Parsing... 2015-12-17 15:18:00
Parsing... 2015-12-17 15:48:00
Parsing... 2015-12-17 16:18:00
Parsing... 2015-12-17 16:48:00
Parsing... 2016-01-12 07:46:00
Parsing... 2016-01-12 08:17:00
Parsing... 2016-01-12 08:47:00
Parsing... 2016-01-12 09:17:00
Parsing... 2016-01-12 09:47:00
Parsing... 2016-01-12 10:17:00
Parsing... 2016-01-12 10:47:00
Parsing... 2016-01-12 11:17:00
Parsing... 2016-01-12 11:47:00
Parsing... 2016-01-12 12:17:00
Parsing... 2016-01-12 12:47:00
Parsing... 2016-01-12 13:17:00
Parsing... 2016-01-12 13:47:00
Parsing... 2016-01-12 14:17:00
Parsing... 2016-01-12 14:47:00
Parsing... 2016-01-12 15:17:00
Parsing... 2016-01-12 15:47:00
Parsing... 2016-01-12 16:17:00
Parsing... 2016-01-12 16:47:00
Parsing... 2016-01-12 17:17:00
Parsing... 2016-01-13 07:48:00
Parsing... 2016-01-13 08:18:00
Parsing... 2016-01-13 08:48:00
Parsing... 2016-01-13 09:18:00
Parsing... 2016-01-13 09:48:00
Parsing... 2016-01-13 10:18:00
Parsing... 2016-01-13 10:48:00
Parsing... 2016-01-13 11:18:00
Parsing... 2016-01-13 11:48:00
Parsing... 2016-01-13 12:18:00
Parsing... 2016-01-13 12:48:00
Parsing... 2016-01-13 13:18:00
Parsing... 2016-01-13 13:48:00
Parsing... 2016-01-13 14:18:00
Parsing... 2016-01-13 14:48:00
Parsing... 2016-01-13 15:18:00
Parsing... 2016-01-13 15:48:00
Parsing... 2016-01-13 16:18:00
Parsing... 2016-01-13 16:48:00
Parsing... 2016-01-15 07:35:00
Parsing... 2016-01-15 08:05:00
Parsing... 2016-01-15 08:35:00
Parsing... 2016-01-15 09:05:00
Parsing... 2016-01-15 09:35:00
Parsing... 2016-01-15 10:05:00
Parsing... 2016-01-15 10:35:00
Parsing... 2016-01-15 11:05:00
Parsing... 2016-01-15 11:35:00
Parsing... 2016-01-15 12:05:00
Parsing... 2016-01-15 12:35:00
Parsing... 2016-01-15 13:05:00
Parsing... 2016-01-15 13:35:00
Parsing... 2016-01-15 14:05:00
Parsing... 2016-01-15 14:35:00
Parsing... 2016-01-15 15:05:00
Parsing... 2016-01-15 15:35:00
Parsing... 2016-01-15 16:05:00
Parsing... 2016-01-15 16:35:00
Parsing... 2016-01-15 17:05:00
Parsing... 2016-01-16 07:35:00
Parsing... 2016-01-16 08:05:00
Parsing... 2016-01-16 08:35:00
Parsing... 2016-01-16 09:05:00
Parsing... 2016-01-16 09:35:00
Parsing... 2016-01-16 10:05:00
Parsing... 2016-01-16 10:35:00
Parsing... 2016-01-16 11:05:00
Parsing... 2016-01-16 11:35:00
Parsing... 2016-01-16 12:05:00
Parsing... 2016-01-16 12:35:00
Parsing... 2016-01-16 13:05:00
Parsing... 2016-01-16 13:35:00
Parsing... 2016-01-16 14:05:00
Parsing... 2016-01-16 14:35:00
Parsing... 2016-01-16 15:05:00
Parsing... 2016-01-16 15:35:00
Parsing... 2016-01-16 16:05:00
Parsing... 2016-01-16 16:35:00
Parsing... 2016-01-16 17:05:00
Parsing... 2016-01-18 07:35:00
Parsing... 2016-01-18 08:05:00
Parsing... 2016-01-18 08:35:00
Parsing... 2016-01-18 09:05:00
Parsing... 2016-01-18 09:35:00
Parsing... 2016-01-18 10:05:00
Parsing... 2016-01-18 10:35:00
Parsing... 2016-01-18 11:05:00
Parsing... 2016-01-18 11:35:00
Parsing... 2016-01-18 12:05:00
Parsing... 2016-01-18 12:35:00
Parsing... 2016-01-18 13:05:00
Parsing... 2016-01-18 13:35:00
Parsing... 2016-01-18 14:05:00
Parsing... 2016-01-18 14:35:00
Parsing... 2016-01-18 15:05:00
Parsing... 2016-01-18 15:35:00
Parsing... 2016-01-18 16:05:00
Parsing... 2016-01-18 16:35:00
Parsing... 2016-01-18 17:05:00

Convert the car count date/time and car count numbers into a Pandas DataFrame.

In [9]: # Hint: use from_dict function

We now have time series for the car count which we can use to do analysis on. Let's try to calculate the average
car count by hour of the day.

In [10]: # Use groupby function

Plot the car count by hour DataFrame. We get a very intuitive result, with more cars present at the start of the
workday and then rapidly dropping at the end of the working day.

In [11]:

Extending this analysis to create a car count for retailer car parks
We've created a time series for one car park over a few weeks. In practice, if we wanted to track the car count for
a retailer, we would need to replicate this analysis for a large number of their car parks. Typically, such images
would be sourced from satelites as opposed to on the ground CCTV, which we've used here, given we would
likely not have access to such CCTV.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy