Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix exception for no data with YahooDailyReader #994

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Borda
Copy link

@Borda Borda commented Aug 8, 2024

addresses issue when data are not found in requested page, to reproduce:

import pandas_datareader.data as web

# Fetch stock data using pandas_datareader
def fetch_stock_data(symbol='AAPL', start_date='2020-01-01', end_date='2021-01-01'):
    df = web.DataReader(symbol, 'yahoo', start_date, end_date)
    return df['Close'].values

print(fetch_stock_data())

cc: @bashtage

@@ -149,7 +149,7 @@ def _read_one_data(self, url, params):
try:
j = json.loads(re.search(ptrn, resp.text, re.DOTALL).group(1))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if a patter is not found it crashes with different exception:
AttributeError: 'NoneType' object has no attribute 'group'

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.88%. Comparing base (a1cf7a2) to head (74f9a90).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #994      +/-   ##
==========================================
- Coverage   68.34%   66.88%   -1.47%     
==========================================
  Files          65       65              
  Lines        2894     2893       -1     
  Branches      463      463              
==========================================
- Hits         1978     1935      -43     
- Misses        838      882      +44     
+ Partials       78       76       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants