Python Forum
1 I cant read many stocks(list) with pandas-datareader from yahoo
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
1 I cant read many stocks(list) with pandas-datareader from yahoo
#1
import pandas_datareader as pdr
import datetime 
import pandas as pd

largecap = pd.read_excel('largecap.xlsx')
antalrader = len(largecap.index)

stocks = list()

x = 0
while x < antalrader:
   stocks.insert(x, largecap.Yahoo[x])
   x += 1


print(type(stocks[121]))
ls_key = 'Adj Close'
start = datetime.datetime(2016, 1, 1)
end = datetime.datetime(2016, 1, 31)   
f = pdr.DataReader(stocks, 'yahoo', start, end)
print(f)
Error message:
/Users/david.soderstrom/anaconda3/lib/python3.6/site-packages/pandas_datareader/yahoo/daily.py:136: SymbolWarning: Failed to read symbol: 'AHSL.ST', replacing with NaN.
 warnings.warn(msg.format(sym), SymbolWarning)
Why can't i read the symbols from yahoo? I have 122 values in the list. If i write:
pdr.DataReader(AHSL.ST, 'yahoo', start, end)
It does read correctly from yahoo.
Reply
#2
The only thing I can think of is that there's some character you can't see there, like a unicode space or something.  What do you see if you do: print([ord(ch) for ch in stocks[121]])?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [pandas] How to reshape the list Mekala 6 472 Jul-26-2020, 12:49 AM
Last Post: Mekala
  Can't read text file with pandas zinho 6 3,668 May-24-2020, 06:13 AM
Last Post: azajali43
  Read json array data by pandas vipinct 0 359 Apr-13-2020, 02:24 PM
Last Post: vipinct
  pandas.read_sas with chunksize: IndexError list index out of range axelle 0 461 Jan-28-2020, 09:30 AM
Last Post: axelle
  getting trailing zeros with 1 during pandas read fullstop 1 993 Jan-05-2020, 04:01 PM
Last Post: ichabod801
  pandas DataReader error on all data sources glidecode 5 11,210 Sep-25-2019, 02:10 PM
Last Post: perfringo
  Read csv file from Yahoo Finance ian 3 1,293 Sep-22-2019, 06:47 AM
Last Post: ndc85430
  Read Nested JSON with pandas.io.json palo173 4 5,628 Apr-29-2019, 01:25 PM
Last Post: palo173
  Inserting data from python list into a pandas dataframe mahmoud899 0 775 Mar-02-2019, 04:07 AM
Last Post: mahmoud899
  read complex file with both pandas and not Diedro 1 926 Jan-29-2019, 05:26 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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