Throughout the first 11 chapters of this book, we looked at pandas and how you perform various tasks with the library. We focused mostly on how to work with pandas, often using made-up data created to demonstrate the feature but with an occasional diversion now and then into some more real-world examples.
In this final chapter, we will use pandas to perform a number of different financial analyses of stock data obtained from Yahoo! Finance. We will briefly cover a number of topics in financial analysis. The focus will be on using pandas to derive results from the domain of finance, specifically, time-series stock data, and not on details of the financial theory.
Specifically, in this chapter, we will progress through the following tasks:
The first step is to make sure that we have included all of the necessary Python libraries for all of the tasks that will be performed. This includes matplotlib for graphs, datetime
to manage various dates and time in the data, a few methods from NumPy, and random number capabilities from the random library:
In [1]: # necessary imports for the workbook import pandas as pd import pandas.io.data import numpy as np import datetime import matplotlib.pyplot as plt # Set some pandas options pd.set_option('display.notebook_repr_html', False) pd.set_option('display.max_columns', 6) pd.set_option('display.max_rows', 10) pd.set_option('display.width', 78) pd.set_option('precision', 4) # do all our graphics inline %matplotlib inline
52.15.55.18