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

KeyError: 'Adj Close' #1

Open
john012343210 opened this issue May 11, 2020 · 1 comment
Open

KeyError: 'Adj Close' #1

john012343210 opened this issue May 11, 2020 · 1 comment

Comments

@john012343210
Copy link

KeyError                                  Traceback (most recent call last)
<ipython-input-1-f192bf0f8e05> in <module>
     15 if __name__ == "__main__":
     16     app = QApplication(sys.argv)
---> 17     window = MainWindow()
     18     sys.exit(app.exec_())

<ipython-input-1-f192bf0f8e05> in __init__(self)
      9         super(MainWindow, self).__init__()
     10         self.graph = QStockWidget()
---> 11         self.graph.plot("AAPL")
     12         self.setCentralWidget(self.graph)
     13         self.show()

C:\ProgramData\Anaconda3\lib\site-packages\pyqt_finance\widget.py in plot(self, *args)
     46         self.figure.suptitle(ticker)
     47         ax = self.figure.add_subplot(111)
---> 48         ax.plot(dates, data["Adj Close"])
     49         self.canvas.draw()
     50 

C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key)
   2925             if self.columns.nlevels > 1:
   2926                 return self._getitem_multilevel(key)
-> 2927             indexer = self.columns.get_loc(key)
   2928             if is_integer(indexer):
   2929                 indexer = [indexer]

C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
   2657                 return self._engine.get_loc(key)
   2658             except KeyError:
-> 2659                 return self._engine.get_loc(self._maybe_cast_indexer(key))
   2660         indexer = self.get_indexer([key], method=method, tolerance=tolerance)
   2661         if indexer.ndim > 1 or indexer.size > 1:

pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'Adj Close'
@lpiatti
Copy link

lpiatti commented Oct 28, 2021

Hi Sunset, I just found this old package and verified that you are right.
The fix is very easy, you have to change "Adj Close" with "Close": probably something changed in yahoo libs in these years.

I also attach a source file with better management of start_date and end_date of the graph.
The file self contains a main routine … so you can start it without installing the lib.

If the author has some spare time can:

  • set the key to find as a parameter in config to prevent future changes
  • check if my little addition is something to consider in a newer version ;-)

KR
Luigi

widget_fix.zip

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

No branches or pull requests

2 participants