0

I want to:

1-import a column of tickers with the number of 88 in excel file

2-get the data of historical price for these list of tickers

3-export the data back to excel

My problem:

filename=r'C:\Users\User\Desktop\data.xlsx'

yeah = pd.read_excel(filename, sheet_name='entry')

stock = []

stock = list(yeah['stock_name'])

print(stock)

Please check below link of photo shown my error [1]: https://i.stack.imgur.com/kizuW.png

How can I remove all these \xa0 and nan? and making it workable for the next step?

symbol_list=[stock]

for symbol in symbol_list:

    symbol_adj_close[symbol] = web.get_data_yahoo([symbol],start,end)['Adj Close']

    print(symbol)

Thanks!

Sowjanya R Bhat
  • 1,128
  • 10
  • 19
kenneth c
  • 21
  • 1
  • 5
  • 1
    [How to remove \xa0 from string in Python?](https://stackoverflow.com/questions/10993612/how-to-remove-xa0-from-string-in-python) – Ynjxsjmh Aug 23 '20 at 13:42

1 Answers1

0

This line iterates over all elements in stock and:

  1. Filers out those that are nan in panda in if not pd.isna(s).
  2. Removes the \xa0 in s.replace('\xa0', ' ').

stock = [ s.replace('\xa0', ' ') for s in stock if not pd.isna(s) ]
Aviv Yaniv
  • 6,188
  • 3
  • 7
  • 22