How to do it...

Let's see how we can extract statistics from time series data:

  1. Create a new Python file and import the following packages (the full code is given in the extract_stats.py file that is provided for you):
import pandas as pd 
import matplotlib.pyplot as plt 
from convert_to_timeseries import convert_data_to_timeseries 

The convert_to_timeseries function is the function we defined in the previous recipe, Transforming data into a time series format, that read an input file and converted sequential observations into time-indexed data.

  1. We will use the same text file that we used in the previous recipes for analysis (data_timeseries.txt):
# Input file containing data 
input_file = 'data_timeseries.txt' 
  1. Load both the data columns ...

Get Python Machine Learning Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.