Slicing time series data

In this recipe, we will learn how to slice time series data using pandas. This will help you extract information from various intervals in the time series data. We will learn how to use dates to handle subsets of our data.

How to do it…

  1. Create a new Python file, and import the following packages:
    import numpy as np
    import pandas as pd
    import matplotlib.pyplot as plt
    
    from convert_to_timeseries import convert_data_to_timeseries
  2. We will use the same text file that we used in the previous recipe to slice and dice the data:
    # Input file containing data
    input_file = 'data_timeseries.txt'
  3. We will use the third column again:
    # Load data
    column_num = 2
    data_timeseries = convert_data_to_timeseries(input_file, column_num)
  4. Let's assume that ...

Get Python: Real World Machine Learning 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.