python3使用pandas获取股票数据的方法

yipeiwu_com7年前Python基础

如下所示:

from pandas_datareader import data, wb
from datetime import datetime
import matplotlib.pyplot as plt
 
end = datetime.now()
start = datetime(end.year - 1, end.month, end.day)
alibaba = data.DataReader('BABA', 'yahoo', start, end)
 
alibaba['Adj Close'].plot(legend=True, figsize=(10,4))
plt.show()

pandas版本0.23.1

进入命令行窗口,在python安装目录下,进入Scripts,输入命令pip install pandas

python3 pandas获取股票数据

pandas_datareader版本0.6.0

进入命令行窗口,在python安装目录下,进入Scripts,输入命令pip install pandas_datareader

问题:

运行时报错:ImportError: cannot import name 'is_list_like'

解决:

修改D:\Python36\Lib\site-packages\pandas_datareader\fred.py

将from pandas.core.common import is_list_like改为from pandas.api.types import is_list_like

问题:

运行时报错:raise ImmediateDeprecationError(DEP_ERROR_MSG.format('Yahoo Daily'))

解决:

修改D:\Python36\Lib\site-packages\pandas_datareader\data.py

注释掉raise ImmediateDeprecationError(DEP_ERROR_MSG.format('Yahoo Daily'))

以上这篇python3使用pandas获取股票数据的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python通过TensorFlow卷积神经网络实现猫狗识别

这份数据集来源于Kaggle,数据集有12500只猫和12500只狗。在这里简单介绍下整体思路 处理数据 设计神经网络 进行训练测试 1. 数据处理 将图片数据处理为 t...

对Python3中的print函数以及与python2的对比分析

对Python3中的print函数以及与python2的对比分析

本文首先介绍在python3中print函数的应用,然后对比在pyhton2中的应用。(本文作者所用版本为3.6.0) 首先我们通过help(print)命令来查看print函数的相关信...

python中将阿拉伯数字转换成中文的实现代码

复制代码 代码如下: #!/usr/bin/python #-*- encoding: utf-8 -*- import types class NotIntegerError(Exce...

基于pip install django失败时的解决方法

使用pip安装Django时报错,先是: C:\Users\admin>pip install django Collecting django Retrying (Re...

Python基于pandas实现json格式转换成dataframe的方法

本文实例讲述了Python基于pandas实现json格式转换成dataframe的方法。分享给大家供大家参考,具体如下: # -*- coding:utf-8 -*- #!pyth...