1、使用tushare金融数据包
地址及操作说明:http://tushare.org/index.html#id3
安装步骤:
- 安装Python
- 安装pandas
- lxml也是必须的,正常情况下安装了Anaconda后无须单独安装,如果没有可执行:pip install lxml
- 方式1:pip install tushare
- 方式2:访问https://pypi.python.org/pypi/Tushare/下载安装
如果经过上述步骤,部分包还是出错,可能尝试卸载重装该包,或者看提示缺什么包,对应安装。
2、简单使用
获取今天所有股票行情数据
import tushare as ts
print(type(ts.get_today_all()))
返回为pandas.core.frame.DataFrame'格式,需要使用pandas相关方法去读取和处理。
3、pandas使用小记
(1)DataFrame操作
打印列名:df.columns
打印整列数据:df['column_name'] ,df[row_start_index, row_end_index] 选取指