Pandas Yahoo Finance: AttributeError: ‘Index’ 对象没有属性 ‘tz_localize’

huangapple go评论69阅读模式
英文:

Pandas Yahoo Finance: AttributeError: 'Index' object has no attribute 'tz_localize'

问题

我遇到了这个错误:在尝试使用历史函数时出现 AttributeError: 'Index' 对象没有属性 'tz_localize'... 请查看一下
Pandas Yahoo Finance: AttributeError: ‘Index’ 对象没有属性 ‘tz_localize’

英文:

I am getting this error: AttributeError: 'Index' object has no attribute 'tz_localize' when i try to use the history function... Please have a look
Pandas Yahoo Finance: AttributeError: ‘Index’ 对象没有属性 ‘tz_localize’

答案1

得分: 1

我无法重现这个问题,使用0.2.18(最新版本):

import yfinance as yf

tesla_stk = yf.Ticker("TSLA")

teslta_data = tesla_stk.history(period="max")

输出:

print(teslta_data)

                  Open   High    Low  Close     Volume  Dividends  Stock Splits
Date                                                                           
2010-06-29 0...   1.27   1.67   1.17   1.59  281494500       0.00          0.00
2010-06-30 0...   1.72   2.03   1.55   1.59  257806500       0.00          0.00
2010-07-01 0...   1.67   1.73   1.35   1.46  123282000       0.00          0.00
...
2023-05-15 0... 167.66 169.76 164.55 166.35  105592500       0.00          0.00
2023-05-16 0... 165.65 169.52 164.35 166.52   96839500       0.00          0.00
2023-05-17 0... 168.41 173.99 167.19 173.11   83557527       0.00          0.00

你可能只需要升级 yfinance 或从 GitHub 上安装它(参见GH1332GH1080)。

英文:

I can't reproduce the issue with 0.2.18 (latest) :

import yfinance as yf

tesla_stk = yf.Ticker("TSLA")

teslta_data = tesla_stk.history(period="max")

Output :

print(teslta_data)

                  Open   High    Low  Close     Volume  Dividends  Stock Splits
Date                                                                           
2010-06-29 0...   1.27   1.67   1.17   1.59  281494500       0.00          0.00
2010-06-30 0...   1.72   2.03   1.55   1.59  257806500       0.00          0.00
2010-07-01 0...   1.67   1.73   1.35   1.46  123282000       0.00          0.00
...                ...    ...    ...    ...        ...        ...           ...
2023-05-15 0... 167.66 169.76 164.55 166.35  105592500       0.00          0.00
2023-05-16 0... 165.65 169.52 164.35 166.52   96839500       0.00          0.00
2023-05-17 0... 168.41 173.99 167.19 173.11   83557527       0.00          0.00

You might just need to upgrade yfinance or install it from GitHub (see GH1332 & GH1080).

huangapple
  • 本文由 发表于 2023年5月18日 00:32:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76274304.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定