机器学习-Python 01:安装与数据
pytho机器学习环境安装与数据获取
首先安装下列pyhton库
pip install numpy
pip install scipy
pip install scikit-learn
pip install matplotlib
pip install pandas
# 获取美国股市数据
pip install quandl
# 获取中国股市数据
pip install bs4
pip install tushare
python获取google股市数据
import pandas as pd
import quandl
df = quandl.get('WIKI/GOOGL')
print(df.head())
df = df[['Adj. Open', 'Adj. High','Adj. Low','Adj. Close','Adj. Volume', ]]
df['HL_PCT'] = (df['Adj. High'] - df['Adj. Close']) / df['Adj. Close'] * 100
df['PCT_change'] = (df['Adj. Close'] - df['Adj. Open']) / df['Adj. Open'] * 100
df = df[['Adj. Close', 'HL_PCT', 'PCT_change', 'Adj. Volume']]
(参考)
python获取中国股市数据
import tushare as ts
ts.get_hist_data('600848')
(参考:知乎,tushare.org)