January 2017
Beginner to intermediate
446 pages
8h 46m
English
Let's get started by learning how to handle time-series data in Pandas. In this section, we will convert a sequence of numbers into time series data and visualize it. Pandas provides options to add timestamps, organize data, and then efficiently operate on it.
Create a new Python file and import the following packages:
import numpy as np import matplotlib.pyplot as plt import pandas as pd
Define a function to read the data from the input file. The parameter index indicates the column number that contains the relevant data:
def read_data(input_file, index):
# Read the data from the input file
input_data = np.loadtxt(input_file, delimiter=',')
Define a lambda function to convert strings to Pandas date format:
Read now
Unlock full access