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 read csv file in 'date/time' chunks MorganSamage 4 1,690 Feb-13-2023, 11:24 AM
Last Post: MorganSamage
Smile How to further boost the data read write speed using pandas tjk9501 1 1,261 Nov-14-2022, 01:46 PM
Last Post: jefsummers
  Yahoo Premium pogere 1 1,272 Jun-01-2022, 11:42 AM
Last Post: pogere
  Comparing results within a list and appending to pandas dataframe Aryagm 1 2,342 Dec-17-2020, 01:08 PM
Last Post: palladium
  [pandas] How to reshape the list Mekala 6 7,350 Jul-26-2020, 12:49 AM
Last Post: Mekala
  Can't read text file with pandas zinho 6 12,087 May-24-2020, 06:13 AM
Last Post: azajali43
  Read json array data by pandas vipinct 0 1,936 Apr-13-2020, 02:24 PM
Last Post: vipinct
  getting trailing zeros with 1 during pandas read fullstop 1 3,584 Jan-05-2020, 04:01 PM
Last Post: ichabod801
  pandas DataReader error on all data sources glidecode 5 18,153 Sep-25-2019, 02:10 PM
Last Post: perfringo
  Read csv file from Yahoo Finance ian 3 4,636 Sep-22-2019, 06:47 AM
Last Post: ndc85430

Forum Jump:

User Panel Messages

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