Skip to content

Commit e5b6d23

Browse files
stoffprofDavid Stephens
authored andcommitted
BUG: Deal with missing keys
Handles cases where 'Data' or 'eventsData' keys are missing
1 parent da18fbd commit e5b6d23

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pandas_datareader/yahoo/daily.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class YahooDailyReader(_DailyBaseReader):
4343
Number of symbols to download consecutively before intiating pause.
4444
interval : string, default 'd'
4545
Time interval code, valid values are 'd' for daily, 'w' for weekly,
46-
'm' for monthly and 'v' for dividend.
46+
'm' for monthly.
4747
"""
4848

4949
def __init__(self, symbols=None, start=None, end=None, retry_count=3,
@@ -146,15 +146,16 @@ def _read_one_data(self, symbol):
146146
prices.columns = map(str.capitalize, prices.columns)
147147
prices['Date'] = to_datetime(prices['Date'], unit='s').dt.date
148148

149-
prices = prices[prices['Data'].isnull()]
149+
if 'Data' in prices.columns:
150+
prices = prices[prices['Data'].isnull()]
150151
prices = prices[['Date', 'High', 'Low', 'Open', 'Close', 'Volume',
151152
'Adjclose']]
152153
prices = prices.rename(columns={'Adjclose': 'Adj Close'})
153154

154155
dfs = {'prices': prices}
155156

156157
# dividends & splits data
157-
if self.get_actions:
158+
if self.get_actions and data['eventsData']:
158159
actions = DataFrame(data['eventsData'])
159160
actions.columns = map(str.capitalize, actions.columns)
160161
actions['Date'] = to_datetime(actions['Date'], unit='s').dt.date
@@ -202,7 +203,6 @@ def _dl_mult_symbols(self, symbols):
202203
dfs[k] = concat(stocks[k]).set_index(['Ticker', 'Date'])
203204
return dfs
204205

205-
206206
def _adjust_prices(hist_data, price_list=None):
207207
"""
208208
Return modifed DataFrame or Panel with adjusted prices based on

0 commit comments

Comments
 (0)