Introduction to Python for Finance
Adina Howe
Instructor
NumPy arrays of data describing the S&P 100: names, prices, earnings, sectors
Explore and analyze sector-specific P/E ratios within companies of the S&P 100
stock_prices = np.array([100, 200, 300])
filter_array = (stock_prices >= 150)
print(filter_array)
[ False True True]
stock_prices = np.array([100, 200, 300])
filter_array = (stock_prices >= 150)
print(stock_prices[filter_array])
[200 300]
Calculate the average and standard deviation of these sector-specific P/E ratios
import numpy as np
average_value = np.mean(my_array)
std_value = np.std(my_array)
Introduction to Python for Finance