Python 金融入門
Adina Howe
Professor
描述 S&P 100 的 NumPy 陣列:names、prices、earnings、sectors
在 S&P 100 公司中探索並分析各產業的本益比(P/E)
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]
計算這些產業本益比的平均與標準差
import numpy as np
average_value = np.mean(my_array)
std_value = np.std(my_array)
Python 金融入門