Performing a time-series analysis

A time-series analysis allows us to view the changes to the data over a specified time period. You see this being used all the time in presentations, on the news, and on application dashboards. It's a fantastic way to view trends.

For this recipe, we're going to use the Accidents data set.

How to do it…

  1. First, import the Python libraries that you need:
    import pandas as pd import numpy as np import matplotlib as plt import matplotlib.pyplot as plt %matplotlib inline Next, define a variable for the accidents data file, import the data, and view the top five rows. accidents_data_file = '/Users/robertdempsey/Dropbox/private/Python Business Intelligence Cookbook/Data/Stats19-Data1979-2004/Accidents7904.csv' accidents = ...

Get Python Business Intelligence Cookbook 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.