Summarize your data with descriptive stats

Importing and Managing Financial Data in Python

Stefan Jansen

Instructor

Be on top of your data

  • Goal: Capture key quantitative characteristics
  • Important angles to look at:
    • Central tendency: Which values are "typical"?
    • Dispersion: Are there outliers?
    • Overall distribution of individual variables
Importing and Managing Financial Data in Python

Central tendency

  • Mean (average): $\displaystyle \bar{x} = \frac{1}{n}\sum_{i=1}^n x_i$
  • Median: 50% of values smaller/larger
  • Mode: most frequent value

Symmetrical distribution

Importing and Managing Financial Data in Python

Central tendency

  • Mean (average): $\displaystyle \bar{x} = \frac{1}{n}\sum_{i=1}^n x_i$
  • Median: 50% of values smaller/larger
  • Mode: most frequent value

Skewed distribution

Importing and Managing Financial Data in Python

Central tendency

  • Mean (average): $\displaystyle \bar{x} = \frac{1}{n}\sum_{i=1}^n x_i$
  • Median: 50% of values smaller/larger
  • Mode: most frequent value

Bimodal distribution

Importing and Managing Financial Data in Python

Calculate summary statistics

nasdaq = pd.read_excel('listings.xlsx', sheet_name='nasdaq', na_values='n/a')
market_cap = nasdaq['Market Capitalization'].div(10**6)
market_cap.mean()
3180.7126214953805
market_cap.median()
225.9684285
market_cap.mode()
0.0
Importing and Managing Financial Data in Python

Calculate summary statistics

marketcaphist.png

Importing and Managing Financial Data in Python

Dispersion

  • Variance: Sum all of the squared differences from mean and divide by $n-1$
    • $\displaystyle var = \frac{1}{n-1}\sum_{i=1}^n(x_i-\bar{x})^2$
  • Standard deviation: Square root of variance
    • $\displaystyle sd = \sqrt{var}$

marketcapvar.png

Importing and Managing Financial Data in Python

Calculate variance and standard deviation

variance = market_cap.var()
print(variance)
648773812.8182
np.sqrt(variance)
25471.0387
market_cap.std()
25471.0387
Importing and Managing Financial Data in Python

Let's practice!

Importing and Managing Financial Data in Python

Preparing Video For Download...