kumaranvpl / predict_stock_price

Predict stock price using fbprophet
5 stars 10 forks source link

Key error #1

Open zpencerguy opened 7 years ago

zpencerguy commented 7 years ago

KeyError Traceback (most recent call last) //anaconda/lib/python3.5/site-packages/pandas/core/indexing.py in _has_valid_type(self, key, axis) 1394 if key not in ax: -> 1395 error() 1396 except TypeError as e:

//anaconda/lib/python3.5/site-packages/pandas/core/indexing.py in error() 1389 raise KeyError("the label [%s] is not in the [%s]" % -> 1390 (key, self.obj._get_axis_name(axis))) 1391

KeyError: 'the label [Sunday] is not in the [index]'

During handling of the above exception, another exception occurred:

KeyError Traceback (most recent call last)

in () 35 if __name__ == "__main__": 36 print("hello") ---> 37 main() in main() 29 plt.show() 30 ---> 31 plt = m.plot_components(forecast) 32 plt.waitforbuttonpress() 33 plt.show() //anaconda/lib/python3.5/site-packages/fbprophet/forecaster.py in plot_components(self, fcst, uncertainty) 699 days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 700 'Friday', 'Saturday'] --> 701 y_weekly = [df_s.loc[d]['weekly'] for d in days] 702 y_weekly_l = [df_s.loc[d]['weekly_lower'] for d in days] 703 y_weekly_u = [df_s.loc[d]['weekly_upper'] for d in days] //anaconda/lib/python3.5/site-packages/fbprophet/forecaster.py in (.0) 699 days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 700 'Friday', 'Saturday'] --> 701 y_weekly = [df_s.loc[d]['weekly'] for d in days] 702 y_weekly_l = [df_s.loc[d]['weekly_lower'] for d in days] 703 y_weekly_u = [df_s.loc[d]['weekly_upper'] for d in days] //anaconda/lib/python3.5/site-packages/pandas/core/indexing.py in __getitem__(self, key) 1294 return self._getitem_tuple(key) 1295 else: -> 1296 return self._getitem_axis(key, axis=0) 1297 1298 def _getitem_axis(self, key, axis=0): //anaconda/lib/python3.5/site-packages/pandas/core/indexing.py in _getitem_axis(self, key, axis) 1464 1465 # fall thru to straight lookup -> 1466 self._has_valid_type(key, axis) 1467 return self._get_label(key, axis=axis) 1468 //anaconda/lib/python3.5/site-packages/pandas/core/indexing.py in _has_valid_type(self, key, axis) 1401 raise 1402 except: -> 1403 error() 1404 1405 return True //anaconda/lib/python3.5/site-packages/pandas/core/indexing.py in error() 1388 "key") 1389 raise KeyError("the label [%s] is not in the [%s]" % -> 1390 (key, self.obj._get_axis_name(axis))) 1391 1392 try: KeyError: 'the label [Sunday] is not in the [index]'
kumaranvpl commented 7 years ago

Hi @zpencerguy .. What is your input

zpencerguy commented 7 years ago

Using APPL when returned error.

def get_historical_stock_price(stock):

print ("Getting historical stock prices for stock ", stock)

url = "http://real-chart.finance.yahoo.com/table.csv?s=%s&ignore=.csv" %(stock)
#print url
c = pd.read_csv(url)
return c

def main(): stock = 'AAPL' df_whole = get_historical_stock_price(stock)