Some ETF Tickers Not Working in Yahoo Finance DataReader
I'm gathering data from a bunch of ETFs through Yahoo Finance using Pandas-Datareader and I'm getting odd errors with a handful of the tickers even though the data seems available. The code is very simple:
start = datetime.datetime(2010, 1, 1) end = datetime.datetime(2017,1,1) for ticker in TICKERS: f = dr.DataReader(ticker, 'yahoo', start, end)
and works for most of my tickers but not all:
EMLP GDVD (Failed to get data for GDVD) AMZA RFDI ARKK ARKW SECT (Failed to get data for SECT)
EMLP works fine. Datareader produces urls like this url for GDVD even though the historical data for GDVD is available on the website. I see the following error in Chrome using the GDVD url:
{"finance": {"error": {"code": "Unauthorized","description": "Invalid cookie"}}}
Is there a way to get historical prices for these tickers? The full list of failed tickers in case anyone can see a pattern:
['GDVD', 'SECT', 'DWLD', 'CCOR', 'DFNL', 'DUSA', 'AIEQ', 'CACG', 'QSY', 'ACT', 'TAXR', 'TTAI', 'FLIO', 'FMDG', 'VGFO', 'FFSG', 'LRGE', 'YLDE', 'VESH', 'DEMS', 'SQZZ'])
- python (pandas) merge within dataframe without for loop
Hi I have the following dataframe:
>df1 code item01 item02 item03 item04 item05 0 1111 nan nan nan nan 440 1 1111 nan nan nan 650 nan 2 1111 nan nan nan nan nan 3 1111 nan nan nan nan nan 4 1111 32 nan nan nan nan 5 1111 nan nan nan nan nan 6 1111 nan nan nan nan nan 7 1111 nan nan nan nan nan 8 1111 nan nan nan nan nan 9 1111 nan nan nan nan nan 10 1111 nan nan nan nan nan 11 2222 20 nan nan nan nan 12 2222 nan nan nan nan nan 13 2222 nan nan nan 5 nan 14 2222 nan 7 nan nan nan 15 2222 nan nan nan nan nan 16 2222 nan nan nan nan nan
How can I merge using 'code' column within the dataframe to get df2 without for loop or iterrows().
>df2 code item01 item02 item03 item04 item05 0 1111 32 130 nan 650 440 1 2222 20 7 nan 5 nan
- How to remove rows after a particular observation is seen for the first time
I have a dataset wherein I have account number and "days past due" with every observation. For every account number, as soon as the "days past due" column hits a code like "DLQ3", I want to remove rest of the rows for that account (even if DLQ3 is the first observation for that account).
My dataset looks like:
Obs_month Acc_No OS_Bal Days_past_due 201005 2000000031 3572.68 NORM 201006 2000000031 4036.78 NORM 200810 2000000049 39741.97 NORM 200811 2000000049 38437.54 DLQ3 200812 2000000049 23923.98 DLQ1 200901 2000000049 35063.88 NORM
So, for account 2000000049, I want to remove all the rows post the date 200812 as now it's in default.
So in all, I want to see when the account hits DLQ3 and when it does I want to remove all the rows post the first DLQ3 observation.
What I tried was to subset the data with all DLQ3 observations and order the observation month in ascending order and getting an unique list of account number which have DLQ3 and their first month of hitting DLQ3. Post that I thought I could do some left_join with the orginal data and use ifelse but the flow is dicey.
- Installing Alpha Vantage in Conda
I was looking to try out Alpha Vantage's API in Python, but I'd like to install it using Anaconda rather than pip. I'm fairly new to conda however.
I searched for alpha_vantage in conda
conda search alpha_vantage
and it says alpha_vantage is not available on my channels. Is there a way to find a channel that has it? I sort of thought that is what the search would be for.
- How can I change the x-axis index date format in matplotlib?
My code below outputs the following image:
from datetime import datetime as dt import matplotlib.pyplot as plt from matplotlib import style import pandas as pd import pandas_datareader.data as web import os start = dt(2017, 1, 1) end = dt.now() df = web.get_data_yahoo('AAPL', start, end, interval = 'd') df['30_sma'] = df['Adj Close'].rolling(window=30, min_periods=None).mean() fig = plt.figure() ax = fig.add_subplot(1, 1, 1) ax.plot(df.index, df['Adj Close']) ax.plot(df.index, df['30_sma']) plt.show()
I would like the date to show up as YYYY-MM-DD or YYYY-MM format. I have tried creating a new column in my data frame made up of the index, but that did not change anything when I plotted it.
- Python data reader having issues fetching data from Yahoo Finance
I am scraping stock data from Yahoo Finance using pythons data reader. The code below works I would say 75% of the time but throws an error the other 25%. Below is the code and below will be error it is displaying. I have searched this issue a few times, but have not found a solution. Hopefully somebody can help me out. Thank you!
Below is the code.
import datetime as dt import pandas as pd import pandas_datareader.data as web start = datetime.datetime(2017, 10, 9) end = datetime.datetime(2017, 10, 11) data = web.DataReader('AAPL', 'yahoo', start, end)
Below is the error
Traceback (most recent call last): File "<pyshell#27>", line 1, in <module> data = web.DataReader('AAPL', 'yahoo', start, end) File "C:\Program Files\Python36\lib\site-packages\pandas_datareader\data.py", line 121, in DataReader session=session).read() File "C:\Program Files\Python36\lib\site-packages\pandas_datareader\yahoo\daily.py", line 115, in read df = super(YahooDailyReader, self).read() File "C:\Program Files\Python36\lib\site-packages\pandas_datareader\base.py", line 181, in read params=self._get_params(self.symbols)) File "C:\Program Files\Python36\lib\site-packages\pandas_datareader\base.py", line 79, in _read_one_data out = self._read_url_as_StringIO(url, params=params) File "C:\Program Files\Python36\lib\site-packages\pandas_datareader\base.py", line 90, in _read_url_as_StringIO response = self._get_response(url, params=params) File "C:\Program Files\Python36\lib\site-packages\pandas_datareader\base.py", line 139, in _get_response raise RemoteDataError('Unable to read URL: {0}'.format(url)) pandas_datareader._utils.RemoteDataError: Unable to read URL:
- Using Quandll with Pandas DataReader suddenly getting a RemoteDataError today?
Here is the code I am using,
import numpy as np import datetime import pandas_datareader as pdr import openpyxl,os end = datetime.datetime(2018,1,11) start = datetime.datetime(2010,1,1) df = pdr.DataReader("NSE/ACC", 'quandl', start, end)
It was working perfectly till yestderday. Now it throws the following error,
An exception of type RemoteDataError occurred. Arguments: ('Unable to read URL:',) There was an error with NSE/ACC
Am I doing something wrong?
- Unable to import Pandas_Datareader
I'm using Python 3.6 in Ubuntu 16.04.
From this very simple program:
import pandas_datareader.data as web import datetime amzn = web.DataReader("AMZN", "yahoo", datetime(2000,1,1), datetime(2015,1,1))
I get this very impressive error list:
Traceback (most recent call last): File "/SAT/time_series.py", line 1, in <module> import pandas_datareader.data as web File "/anaconda/lib/python3.6/site-packages/pandas_datareader/__init__.py", line 3, in <module> from .data import (get_components_yahoo, get_data_famafrench, get_data_google, get_data_yahoo, get_data_enigma, # noqa File "/anaconda/lib/python3.6/site-packages/pandas_datareader/data.py", line 7, in <module> from pandas_datareader.google.daily import GoogleDailyReader File "/anaconda/lib/python3.6/site-packages/pandas_datareader/google/daily.py", line 1, in <module> from pandas_datareader.base import _DailyBaseReader File "/anaconda/lib/python3.6/site-packages/pandas_datareader/base.py", line 3, in <module> import numpy as np File "/anaconda/lib/python3.6/site-packages/numpy/__init__.py", line 146, in <module> from . import add_newdocs File "/anaconda/lib/python3.6/site-packages/numpy/add_newdocs.py", line 13, in <module> from numpy.lib import add_newdoc File "/anaconda/lib/python3.6/site-packages/numpy/lib/__init__.py", line 8, in <module> from .type_check import * File "/anaconda/lib/python3.6/site-packages/numpy/lib/type_check.py", line 11, in <module> import numpy.core.numeric as _nx File "/anaconda/lib/python3.6/site-packages/numpy/core/__init__.py", line 72, in <module> from numpy.testing.nosetester import _numpy_tester File "/anaconda/lib/python3.6/site-packages/numpy/testing/__init__.py", line 10, in <module> from unittest import TestCase File "/anaconda/lib/python3.6/unittest/__init__.py", line 64, in <module> from .main import TestProgram, main File "/anaconda/lib/python3.6/unittest/main.py", line 4, in <module> import argparse File "/SAT/argparse.py", line 1 if len(sys.argv) > 1: ^ SyntaxError: invalid syntax
I've really now idea what is causing this error other than it's occurring when the program tries to import pandas_datareader.
I am new to the data_reader but I'm pretty sure the import command is syntactically correct.
Can anyone suggest what the problem is?