Chapter 3. Descriptive Statistics and Data Analysis

Descriptive statistics is a field that describes data and extracts as much information as possible from it. Basically, descriptive statistics can act like the representative of the data since it summarizes its tendencies, behavior, and trends.

Trading and analysis borrows a lot from the metrics used in descriptive statistics. This chapter covers the main concepts of descriptive statistics and data analysis. I always found that the best educational tools are practical examples, so I will explain these concepts using an example of an economic time series, the consumer price index (CPI).

The CPI measures the prices paid monthly by urban consumers for a selection of products and services; every month a new observation is released to the public, thus forming a continuous time series. The inflation rate between any two time periods is measured by percentage changes in the price index. For example, if the price of bread last year was $1.00 and the price today is $1.01, then the inflation is 1.00%. The CPI is typically released on a year-on-year basis, which means that it is reported as the difference between the current monthly observation and the observation 12 months ago.

Import the CPI data as follows:

# Importing the required library
import pandas_datareader as pdr
# Setting the beginning and end of the historical data
start_date = '1950-01-01'
end_date   = '2023-01-23'
# Creating a dataframe and downloading the CPI data
cpi 

Get Deep Learning for Finance 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.