zoukankan      html  css  js  c++  java
  • python使用问题 "The pandas.io.data module is moved to a separate package "

     1 import pandas as pd
     2 import datetime
     3 import pandas.io.data as web
     4 import matplotlib.pyplot as plt
     5 from matplotlib import style
     6 
     7 style.use('ggplot') 8 
     9 start = datetime.datetime(2010,1,1)
    10 end = datetime.datetime(2015,1,1)
    11 
    12 df = web.DataReader("XOM","yahoo",start,end)
    13 
    14 print(df.head())
    15 
    16 df['Adj Close'].plot()
    17 
    18 plt.show()

    问题:

    "C:\Program Files\Anaconda3\python.exe" C:/Users/Administrator/PycharmProjects/untitled1/new.py
    Traceback (most recent call last):
    File "C:/Users/Administrator/PycharmProjects/untitled1/new.py", line 3, in <module>
    import pandas.io.data as web
    File "C:\Program Files\Anaconda3\lib\site-packages\pandas\io\data.py", line 2, in <module>
    "The pandas.io.data module is moved to a separate package "
    ImportError: The pandas.io.data module is moved to a separate package (pandas-datareader). After installing the pandas-datareader package (https://github.com/pandas-dev/pandas-datareader), you can change the import ``from pandas.io import data, wb`` to ``from pandas_datareader import data, wb``.

    Process finished with exit code 1

    解决:

    1、安装pandas-datareader

    pip install pandas-datareader
    2、修改代码

    import pandas.io.data as web

    改为
    import pandas_datareader.data as web

    import pandas as pd
    import datetime
    import pandas_datareader.data as web
    import matplotlib.pyplot as plt
    from matplotlib import style
    
    style.use('ggplot')
    
    start = datetime.datetime(2010,1,1)
    end = datetime.datetime(2015,1,1)
    
    df = web.DataReader("XOM","yahoo",start,end)
    
    print(df.head())
    
    df['Adj Close'].plot()
    
    plt.show()




  • 相关阅读:
    java中的定时器
    JAVA中的定时器
    jQuery中的show()和hide()、fadeIn()和fadeOut()、slideDown()和slideUp用法
    ArrayList和LinkedList区别以及list,set,map三者的区别
    java.util包常用的类和接口
    字节流 字符流 输入流 输出流
    运行时异常和checked异常异同
    exception和error异同
    MVC控制器传递多个实体类集合到视图的方案总结
    利用Asp.net和Sql Server实现留言板功能
  • 原文地址:https://www.cnblogs.com/ttrrpp/p/6668675.html
Copyright © 2011-2022 走看看