Book Image

Learning pandas - Second Edition

By : Michael Heydt
Book Image

Learning pandas - Second Edition

By: Michael Heydt

Overview of this book

You will learn how to use pandas to perform data analysis in Python. You will start with an overview of data analysis and iteratively progress from modeling data, to accessing data from remote sources, performing numeric and statistical analysis, through indexing and performing aggregate analysis, and finally to visualizing statistical data and applying pandas to finance. With the knowledge you gain from this book, you will quickly learn pandas and how it can empower you in the exciting world of data manipulation, analysis and science.
Table of Contents (16 chapters)

Calculating the volatility of stocks

The volatility of a stock is a measurement of the amount of change of variance in the price of a stock over a specific time-period. It is common to compare the volatility of a stock to another stock to get a feel for which may have less risk, or to a market index to compare the stock's volatility to the overall market. Generally, the higher the volatility, the riskier the investment is in that stock.

Volatility is calculated by taking a rolling-window standard deviation on the percentage change in a stock (and scaling it relative to the size of the window). The size of the window affects the overall result. The wider a window, the less representative the measurement will become. As the window narrows, the result approaches the standard deviation. So, it is a bit of an art to pick the proper window size, based on the data sampling frequency...