JEON MINHO
JEON MINHO

Reputation: 1

TypeError: string indices must be integers <-- How do I?

My code:

import pandas_datareader.data as web

all_data = {ticker: web.get_data_yahoo(ticker)
            for ticker in ['AAPL', 'IBM', 'MSFT', 'GOOG']}

The error when I execute it:

Traceback (most recent call last)
    <ipython-input-27-dc1fe894f539> in <cell line: 1>()
    ----> 1 all_data = {ticker: web.get_data_yahoo(ticker)
      2             for ticker in ['AAPL', 'IBM', 'MSFT', 'GOOG']}

    3 frames
    /usr/local/lib/python3.10/dist-packages/pandas_datareader/yahoo/daily.py in _read_one_data(self, url, params)
    151         try:
    152             j = json.loads(re.search(ptrn, resp.text, re.DOTALL).group(1))
--> 153             data = j["context"]["dispatcher"]["stores"]["HistoricalPriceStore"]
    154         except KeyError:
    155             msg = "No data fetched for symbol {} using {}"

   TypeError: string indices must be integers

I'm beginner. I'm studying with the book: Python for Data Analysis (Orelly)

Upvotes: -3

Views: 146

Answers (1)

alfawal
alfawal

Reputation: 57

This package seems deprecated as the last commit was on Mar 17 2022 and has around 120 active issues.

Sorry to say it but, you may consider another resource to learn from that does not require a package to be constantly updated with an API or is actively maintained.

You may read this blog for more tips on how you can pick a good package: https://medium.com/plumbersofdatascience/how-to-find-a-good-python-package-2fd3abbb20f1

Good luck!

Upvotes: 0

Related Questions