pandas-datareader

Error "string indices must be integer" when selecting yahoo finance stock data with "start" and "end" dates

Error "string indices must be integer" when selecting yahoo finance stock data with "start" and "end" dates Question: I want to create a simple script that pulls stock data from yahoo finance with pandas_datareader package: from pandas_datareader import data stocks = data.DataReader(‘MSFT’, ‘yahoo’, start=’2020-01-14′, end=’2023-01-14′) but the code gets me "string indices must be integers" …

Total answers: 2

"TypeError: string indices must be integers" when getting data of a stock from Yahoo Finance using Pandas Datareader

"TypeError: string indices must be integers" when getting data of a stock from Yahoo Finance using Pandas Datareader Question: import pandas_datareader end = "2022-12-15" start = "2022-12-15" stock_list = ["TATAELXSI.NS"] data = pandas_datareader.get_data_yahoo(symbols=stock_list, start=start, end=end) print(data) When I run this code, I get error "TypeError: string indices must be integers". Edit : I have updated …

Total answers: 5

In python, get inconsistent returns when trying to reverse Pandas DataFrame values

In python, get inconsistent returns when trying to reverse Pandas DataFrame values Question: I am trying to reverse values of DataFrame in Python as in the following codes. Strangely, x retuns what expected, but not y. import pandas as pd import pandas_datareader as pdr x = pdr.DataReader(‘TQQQ’, data_source=’yahoo’, start=’2000-01-01′) y = pdr.DataReader(‘^NDX’, data_source=’yahoo’, start=’2000-01-01′) # …

Total answers: 2

Shading between two lines

Shading between two lines Question: I want to use axvspan() function to visualize a DataFrame that I obtained using Pandas DataReader.But when I use the the following codes, I saw an error and there is no shading in subplots. What should I do? Thank you. import matplotlib.pyplot as plt import pandas_datareader.data as pdr import pandas …

Total answers: 1

How to fix new unable to read URL error in python for yahoo finance

How to fix new unable to read URL error in python for yahoo finance Question: I have been using this code to extract (scrape) stock prices from Yahoo Finance for the last year, but now it produces an error. Does anyone know why this is happening and how to fix it? # Importing necessary packages …

Total answers: 6

Replacing the missing value Using Pandas

Replacing the missing value Using Pandas Question: {‘Country’: ‘USA’, ‘Age’: ’52’, ‘Sal’: ‘12345’, ‘OnWork’: ‘No’} {‘Country’: ‘UK’, ‘Age’: ’23’, ‘Sal’: ‘1142’, ‘OnWork’: ‘Yes’} {‘Country’: ‘MAL’, ‘Age’: ’25’, ‘Sal’: ‘4456’, ‘OnWork’: ‘No’} {‘Country’: ‘MAL’, ‘Age’: ’25’, ‘Sal’: ‘4456’, ‘OnWork’: ‘No’} {‘Country’: ‘MAL’, ‘Age’: ‘?’, ‘Sal’: ‘2345’, ‘OnWork’: ‘Yes’} {‘Country’: ‘MAL’, ‘Age’: ’25’, ‘Sal’: ‘3342’, ‘OnWork’: ‘Yes’} …

Total answers: 4

Getting Quandl Data via Pandas Data-Reader

Getting Quandl Data via Pandas Data-Reader Question: I am having trouble using pandas-datareader to import data from Quandl. Here is the code that I have tried (with a real API key): import pandas_datareader.data as pdr from datetime import date start=date(1970,1,1) end=date.today() ticker=’F’ qkey=[My API Key] pdr.QUANDL_API_KEY=qkey QUANDL_API_KEY=qkey pdrquandl=pdr.DataReader(‘WIKI/’+ticker,’quandl’,start,end) pdrquandl=pdr.DataReader(‘WIKI/’+ticker,’quandl’,start,end,api_key=qkey) I get the following error messages …

Total answers: 3

How to show a pandas dataframe into a existing flask html table?

How to show a pandas dataframe into a existing flask html table? Question: This may sound a noob question, but I’m stuck with it as Python is not one of my best languages. I have a html page with a table inside it, and I would like to show a pandas dataframe in it. What …

Total answers: 6

Getting a Request Error 404 in Python while accessing an API

Getting a Request Error 404 in Python while accessing an API Question: Previously, I used a Morningstar API to get stock data; however, now that I am away from USA for a week, I am not being able to access the data. This is the code snippet: import datetime as dt from dateutil.relativedelta import relativedelta …

Total answers: 2

import pandas_datareader gives ImportError: cannot import name 'is_list_like'

import pandas_datareader gives ImportError: cannot import name 'is_list_like' Question: I am working in a virtual environment. I am able to import and work in pandas without any error but when I am trying to import pandas_datareader import pandas as pd import numpy as np import matplotlib.pyplot as plt import datetime as dt from matplotlib import …

Total answers: 6