-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Ticker.history: history's index is not of type DateTimeIndex when dividend and split tables are empty #937
Comments
I have found out that the issue occurs when upgrading pandas from 1.3.5 to 1.4.0. Staying with pandas 1.3.5 doesn't cause the issue shared above. |
Thank you for identifying the issue is with numpy. pip install pandas==1.3.5 resolved the issue for me. Here are the error messages I experienced when using yfinance in a virtual environment:
This happens whenever I try to download ticker data with 'period'. |
Several issues might have been introduced with 1.4.0. See <ranaroussi/yfinance#937>
Glad this was fixed, but the update isn't on pip, it's still at 0.1.69. I'm not familiar with how releases work on pip, is it automated and just takes a while or something else? |
@psbj you need to release a new version with the fix I think. There seems to be a GitHub action to do it. @ranaroussi tried to run it to deploy the newest package but it seems that it tried to deploy with version=0.1.169 that was already there instead of version=0.1.170. |
@psbj, @ranaroussi has just updated the version and released the version with the fix. |
Thank-you so much, I had been bashing my head all weekend over a resolution when trying out Part Time Larry's (@hackingthemarkets) YouTube video "PyAlgoTrade Tutorial (Part 2) - Backtesting Basics" (https://www.youtube.com/watch?v=cdeftn1AZO8). New to Python, been a C# guy for years, this is a whole lot of fun! |
Issue:
Ticker.history (line 295):
E AttributeError: 'Index' object has no attribute 'tz_localize'
Reason:
During the concatenation of a proper price table with empty dividend and split tables, the price table's index has changed from pandas.DatetimeIndex to pandas.Index because the empty tables had this index type.
Proposed solution:
Modify parse_actions (in utils.py) to initialise the dividend and split tables with :
dividends = _pd.DataFrame(columns=["Dividends"], index=_pd.DatetimeIndex([]))
splits = _pd.DataFrame(columns=["Stock Splits"], index=_pd.DatetimeIndex([]))
Local modules' versions:
finance : 0.1.69
pandas : 1.4.0
python : 3.10
The text was updated successfully, but these errors were encountered: