Python Forum
How do you put quotations around a result from a for loop?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do you put quotations around a result from a for loop?
#11
I'm getting the following:

KeyError: 0

It starts with the following
97, in get_loc
return self._engine.get_loc(key)
Reply
#12
please, post full traceback in error tags
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#13
Hi buran, I apologize (I'm a newb and have much to learn).

This is the entire respose:

Error:
97, in get_loc return self._engine.get_loc(key) File "pandas/_libs/index.pyx", line 107, in pandas._libs.index.IndexEngine.get_loc File "pandas/_libs/index.pyx", line 131, in pandas._libs.index.IndexEngine.get_loc File "pandas/_libs/hashtable_class_helper.pxi", line 1607, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas/_libs/hashtable_class_helper.pxi", line 1614, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: 0 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "Stockdata_Volume, Price Quote, Beta1.py", line 23, in <module> for x in read[0]: File "C:\Users\andre\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\frame.py", line 2995, in __getitem__ indexer = self.columns.get_loc(key) File "C:\Users\andre\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\indexes\base.py", line 2899, in get_loc return self._engine.get_loc(self._maybe_cast_indexer(key)) File "pandas/_libs/index.pyx", line 107, in pandas._libs.index.IndexEngine.get_loc File "pandas/_libs/index.pyx", line 131, in pandas._libs.index.IndexEngine.get_loc File "pandas/_libs/hashtable_class_helper.pxi", line 1607, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas/_libs/hashtable_class_helper.pxi", line 1614, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: 0
Reply
#14
import pandas as pd

df = pd.read_csv('Stocks.csv', delimiter=',')
 
for ticker in df['Symbol']:
    results = si.get_quote_table(ticker, dict_result=False)
    results.to_csv('Stockdata.csv', index=False)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#15
THANK YOU BURAN! THAT WORKED!!:)
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020