domingo, 24 de mayo de 2020

PYTHON APLICACIONES FINANCIERAS, import pandas_datareader as pdr





primeri importate

aapl = pdr.get_data_yahoo('AAPL', 
                          start=datetime.datetime(2006, 10, 1), 
                          end=datetime.datetime(2012, 1, 1))
# Return first rows of `aapl`
aapl.head()

# Return last rows of `aapl`
aapl.tail()

# Describe `aapl`
aapl.describe()

aapl.to_csv('./aapl_oh2c.csv')
df = pd.read_csv('./aapl_oh2c.csv', header=0, index_col='Date', parse_dates=True)

******************


APPL  

todas ocupan las librerias

import pandas_datareader as pdr
import datetime
import pandas as pd

import matplotlib.pyplot as plt

APPL



AMZN




avance 1
AMZN











ANALISIS 1
up today

# Import matplotlib
import matplotlib.pyplot as plt 

# Isolate the `Adj Close` values and transform the DataFrame
daily_close_px = all_data[['Adj Close']].reset_index().pivot('Date', 'Ticker', 'Adj Close')

# Calculate the daily percentage change for `daily_close_px`
daily_pct_change = daily_close_px.pct_change()

# Plot the distributions
daily_pct_change.hist(bins=50, sharex=True, figsize=(12,8))

# Show the resulting plot
plt.show()

********************************


tickers1withplot00SCATTER.py:46: FutureWarning: pandas.scatter_matrix is deprecated, use pandas.plotting.scatter_matrix instead
  pd.scatter_matrix(daily_pct_change, diagonal='kde', alpha=0.1,figsize=(12,12))






New Books on my link




analysis en 1-5-2021

print("2006 to 2012")     
tickers = ['AMZN', 'MSFT', 'TSLA', 'GOOG'] 
all_data = get(tickers, datetime.datetime(2006, 10, 1), datetime.datetime(2012, 1, 1))

# Import matplotlib import matplotlib.pyplot as plt
# Isolate the 'Adj close' values and transform the DataFrame 
daily_close_px = all_data[['Adj Close']].reset_index().pivot('Date','Ticker', 'Adj Close')
# Calculate the daily percentage change for daily_close_px' 
daily_pct_change = daily_close_px.pct_change()
# Plot the distributions 
daily_pct_change.hist(bins=50, sharex=True, figsize=(12,8))
# Show the resulting plot 
#plt.xlabel('Smarts')
#plt.ylabel('Probability')
plt.title('Calculate the daily percentage change for daily_close_px 2006 to 2012')
plt.show()

# Plot a scatter matrix with the daily_pct_change data 
pd.plotting.scatter_matrix(daily_pct_change, diagonal='kde', alpha=0.1)
# pd.scatter_matrix(daily_pct_change, diagonal='kde', alpha=0.1,figsize(12,12))
#plt.xlabel('Smarts')
#plt.ylabel('Probability')
plt.title('Plot a scatter matrix with the daily_pct_change data 2006 to 2012')








msft = pdr.get_data_yahoo('MSFT', 
                          start=datetime.datetime(2019, 12, 1), 
                          end=datetime.datetime(2021, 1, 4))
                          
#Inspect the index                 
msft.index

#Inspect the columns
msft.columns

#Select only the last 10 observationes of Close
ts= msft['Close'][-10:]

#Check the type of 'ts'
type(ts)

#Inspect the fisrt rows of November-december 2020
print(msft.loc[pd.Timestamp('2019-11-01'):pd.Timestamp('2021-01-04')].head())

#Inspect the first rows of 2020
print(msft.loc['2020'].head())

#Inspect the first rows of 2020
print(msft.iloc[22:43])

# Return first rows of `msft`
msft.head()

# Return last rows of `msft`
msft.tail()

# Describe `msft`
msft.describe()

#Sample 20 rows
print("Sample 20 rows")
sample= msft.sample(20)

#resample to monthly level
print("resample to monthly level")
monthly_msft = msft.resample('M').mean()

#Print 'monthly_msft'
print("monthly_msft")

print(monthly_msft)

#Add a column 'diff' to 'msft'

msft['diff']= msft.Open - msft.Close

print(msft['diff']) 

#imprime al archivo
msft.to_csv('./msft_oh4c.csv')

#lee del archivo
df = pd.read_csv('./msft_oh4c.csv', header=0, index_col='Date', parse_dates=True)

# Plot the closing prices for `msft`
msft['Close'].plot(grid=True)

# Show the plot
plt.title('MSFT 2019-2021 close prices')
plt.show()

plt.title('MSFT 2019-2021 close prices  diferencias')
msft['diff'].plot(grid=True)
plt.show()



second para varias

def get(tickers, startdate, enddate): 
    def data(ticker):
      return (pdr.get_data_yahoo(ticker, start=startdate, end=enddate))
    datas = map (data, tickers) 
    return(pd.concat(datas, keys=tickers, names=['Ticker', 'Date']))
print("2006 to 2012")     
tickers = ['AMZN', 'MSFT', 'TSLA', 'GOOG'] 
all_data = get(tickers, datetime.datetime(2012, 10, 1), datetime.datetime(2021, 1, 1))

# Import matplotlib import matplotlib.pyplot as plt
# Isolate the 'Adj close' values and transform the DataFrame 
daily_close_px = all_data[['Adj Close']].reset_index().pivot('Date','Ticker', 'Adj Close')
# Calculate the daily percentage change for daily_close_px' 
daily_pct_change = daily_close_px.pct_change()
# Plot the distributions 
daily_pct_change.hist(bins=50, sharex=True, figsize=(12,8))
# Show the resulting plot 
#plt.xlabel('Smarts')
#plt.ylabel('Probability')
plt.title('Calculate the daily percentage change for daily_close_px 2012 to 2021')
plt.show()

# Plot a scatter matrix with the daily_pct_change data 
pd.plotting.scatter_matrix(daily_pct_change, diagonal='kde', alpha=0.1)
# pd.scatter_matrix(daily_pct_change, diagonal='kde', alpha=0.1,figsize(12,12))
#plt.xlabel('Smarts')
#plt.ylabel('Probability')
plt.title('Plot a scatter matrix with the daily_pct_change data 2012 to 2021')
print("2006 to 2012")  
plt.show()


amzn = pdr.get_data_yahoo('AMZN', 
                          start=datetime.datetime(2019, 12, 1), 
                          end=datetime.datetime(2021, 1, 5))
  
#Import numpy as np import numpy as np
# Assign `Adj close to "daily_close 
daily_close = amzn[['Adj Close']]

# Daily returns 
daily_pct_change = daily_close.pct_change()
# Replace NA values with a 
daily_pct_change.fillna(0, inplace=True)
# Inspect daily returns 
print(daily_pct_change)

# Daily log returns 
daily_log_returns = np.log(daily_close.pct_change() +1)
# Print daily log returns 
print(daily_log_returns)

# Resample "amzn" to business months, take last observation as value 
monthly = amzn.resample('BM').apply(lambda x: x[-1])
# Calculate the monthly percentage change 
monthly.pct_change()
# Resample amzn" to quarters, take the mean as value per quarter 
quarter = amzn.resample("4M").mean()
# Calculate the quarterly percentage change 
quarter.pct_change()

# Import matplotlib import matplotlib.pyplot as plt
# Plot the distribution of daily_pct_c 
daily_pct_change.hist(bins=50)
# Show the plot 
plt.show()
# Pull up summary statistics
print("daily_pct_change.describe()") 
print(daily_pct_change.describe())

# Calculate the cumulative daily returns 
cum_daily_return = (1 + daily_pct_change).cumprod()
# Print 'cum_daily_return 
print(cum_daily_return)

# Import matplotlib import matplotlib.pyplot as plt
# Plot the cumulative daily returns 
cum_daily_return.plot(figsize=(12,8))
# Show the plot I 
plt.show()

# Resample the cumulative daily return to cumulative monthly return ? 
cum_monthly_return = cum_daily_return.resample("M").mean()
# Print the 'cum_monthly_return 
print(cum_monthly_return)
cum_monthly_return.plot(figsize=(12,8))
# Show the plot I 
plt.show()















desde cero computdora sin nada, pongo python abre microsoft store bajo la ultima version y ejecuto 

C:\Users>cd rober

C:\Users\rober>pyhton PYTHON1.PY
'pyhton' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\rober>python PYTHON1.PY
Traceback (most recent call last):
  File "C:\Users\rober\PYTHON1.PY", line 1, in <module>
    import pandas_datareader as pdr
ModuleNotFoundError: No module named 'pandas_datareader'

C:\Users\rober>python PYTHON1.PY

C:\Users\rober>dir
 Volume in drive C has no label.
 Volume Serial Number is D08A-3849

 Directory of C:\Users\rober

12/26/2020  02:29 PM    <DIR>          .
12/26/2020  02:29 PM    <DIR>          ..
10/03/2020  09:15 PM    <DIR>          .android
10/16/2020  08:35 PM    <DIR>          .cisco
10/03/2020  09:56 PM    <DIR>          .eclipse
12/26/2020  01:27 PM    <DIR>          .idlerc
12/16/2020  02:30 PM    <DIR>          .openshot_qt
12/22/2020  11:23 AM    <DIR>          .p2
10/03/2020  09:56 PM    <DIR>          .tooling
12/10/2020  12:43 AM    <DIR>          3D Objects
12/26/2020  02:29 PM           149,416 aapl_oh2c.csv
12/10/2020  12:44 AM    <DIR>          Contacts
12/26/2020  02:25 PM    <DIR>          Desktop
12/26/2020  01:14 PM    <DIR>          Documents
12/26/2020  02:24 PM    <DIR>          Downloads
10/03/2020  09:34 PM    <DIR>          eclipse
10/03/2020  09:59 PM    <DIR>          eclipse-workspace
10/04/2020  07:49 PM    <DIR>          eclipse-workspace2
10/04/2020  08:30 PM    <DIR>          eclipse-workspace3
10/04/2020  09:08 PM    <DIR>          eclipse-workspace4
10/04/2020  09:49 PM    <DIR>          eclipse-workspace5
12/10/2020  12:44 AM    <DIR>          Favorites
10/04/2020  09:52 PM    <DIR>          IdeaProjects
09/26/2020  12:21 AM    <DIR>          Intel
12/10/2020  12:44 AM    <DIR>          Links
12/15/2020  03:08 PM    <DIR>          Music
12/16/2020  02:17 PM    <DIR>          OneDrive
11/22/2020  03:11 PM    <DIR>          Oracle
12/19/2020  01:25 PM    <DIR>          Pictures
12/16/2020  11:46 AM       110,000,798 prian.mp4
12/24/2020  04:51 PM               128 PUTTY.RND
12/26/2020  02:28 PM               477 PYTHON1.PY
12/10/2020  12:44 AM    <DIR>          Saved Games
12/10/2020  12:44 AM    <DIR>          Searches
12/12/2020  05:33 PM     5,414,812,143 Untitled Project.mp4
12/10/2020  12:44 AM    <DIR>          Videos
               5 File(s)  5,524,962,962 bytes
              31 Dir(s)  10,117,238,784 bytes free

C:\Users\rober>pip install matplotlib
Collecting matplotlib
  Downloading matplotlib-3.3.3-cp39-cp39-win_amd64.whl (8.5 MB)
     |████████████████████████████████| 8.5 MB 36 kB/s
Collecting pillow>=6.2.0
  Downloading Pillow-8.0.1-cp39-cp39-win_amd64.whl (2.1 MB)
     |████████████████████████████████| 2.1 MB 192 kB/s
Requirement already satisfied: python-dateutil>=2.1 in c:\users\rober\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from matplotlib) (2.8.1)
Requirement already satisfied: numpy>=1.15 in c:\users\rober\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from matplotlib) (1.19.4)
Collecting kiwisolver>=1.0.1
  Downloading kiwisolver-1.3.1-cp39-cp39-win_amd64.whl (51 kB)
     |████████████████████████████████| 51 kB 68 kB/s
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3
  Downloading pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
     |████████████████████████████████| 67 kB 622 kB/s
Collecting cycler>=0.10
  Downloading cycler-0.10.0-py2.py3-none-any.whl (6.5 kB)
Requirement already satisfied: six>=1.5 in c:\users\rober\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-dateutil>=2.1->matplotlib) (1.15.0)
Installing collected packages: pillow, kiwisolver, pyparsing, cycler, matplotlib
Successfully installed cycler-0.10.0 kiwisolver-1.3.1 matplotlib-3.3.3 pillow-8.0.1 pyparsing-2.4.7
WARNING: You are using pip version 20.2.3; however, version 20.3.3 is available.
You should consider upgrading via the 'C:\Users\rober\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe -m pip install --upgrade pip' command.

C:\Users\rober>pip install scipy
Collecting scipy
  Downloading scipy-1.5.4-cp39-cp39-win_amd64.whl (31.4 MB)
     |████████████████████████████████| 31.4 MB 97 kB/s
Requirement already satisfied: numpy>=1.14.5 in c:\users\rober\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from scipy) (1.19.4)
Installing collected packages: scipy
Successfully installed scipy-1.5.4
WARNING: You are using pip version 20.2.3; however, version 20.3.3 is available.
You should consider upgrading via the 'C:\Users\rober\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe -m pip install --upgrade pip' command.

C:\Users\rober>pip install numpy
Requirement already satisfied: numpy in c:\users\rober\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (1.19.4)
WARNING: You are using pip version 20.2.3; however, version 20.3.3 is available.
You should consider upgrading via the 'C:\Users\rober\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe -m pip install --upgrade pip' command.

C:\Users\rober>python AMZNclosing

ft Windows [Version 10.0.18363.1256]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\rober>PYTHON

C:\Users\rober>python

C:\Users\rober>pip

Usage:
  C:\Users\rober\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe -m pip <command> [options]

Commands:
  install                     Install packages.
  download                    Download packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  check                       Verify installed packages have compatible dependencies.
  config                      Manage local and global configuration.
  search                      Search PyPI for packages.
  cache                       Inspect and manage pip's wheel cache.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  debug                       Show information useful for debugging.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  --isolated                  Run pip in an isolated mode, ignoring environment variables and user configuration.
  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output. Option is additive, and can be used up to 3 times (corresponding to
                              WARNING, ERROR, and CRITICAL logging levels).
  --log <path>                Path to a verbose appending log.
  --no-input                  Disable prompting for input.
  --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.
  --retries <retries>         Maximum number of retries each connection should attempt (default 5 times).
  --timeout <sec>             Set the socket timeout (default 15 seconds).
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup,
                              (a)bort.
  --trusted-host <hostname>   Mark this host or host:port pair as trusted, even though it does not have valid or any
                              HTTPS.
  --cert <path>               Path to alternate CA bundle.
  --client-cert <path>        Path to SSL client certificate, a single file containing the private key and the
                              certificate in PEM format.
  --cache-dir <dir>           Store the cache data in <dir>.
  --no-cache-dir              Disable the cache.
  --disable-pip-version-check
                              Don't periodically check PyPI to determine whether a new version of pip is available for
                              download. Implied with --no-index.
  --no-color                  Suppress colored output
  --no-python-version-warning
                              Silence deprecation warnings for upcoming unsupported Pythons.
  --use-feature <feature>     Enable new functionality, that may be backward incompatible.
  --use-deprecated <feature>  Enable deprecated functionality, that will be removed in the future.

C:\Users\rober>pip install pandas
Collecting pandas
  Downloading pandas-1.2.0-cp39-cp39-win_amd64.whl (9.3 MB)
     |████████████████████████████████| 9.3 MB 3.2 MB/s
Collecting numpy>=1.16.5
  Downloading numpy-1.19.4-cp39-cp39-win_amd64.whl (13.0 MB)
     |████████████████████████████████| 13.0 MB 80 kB/s
Collecting pytz>=2017.3
  Downloading pytz-2020.5-py2.py3-none-any.whl (510 kB)
     |████████████████████████████████| 510 kB 3.3 MB/s
Collecting python-dateutil>=2.7.3
  Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
     |████████████████████████████████| 227 kB 2.2 MB/s
Collecting six>=1.5
  Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Installing collected packages: numpy, pytz, six, python-dateutil, pandas
  WARNING: The script f2py.exe is installed in 'C:\Users\rober\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed numpy-1.19.4 pandas-1.2.0 python-dateutil-2.8.1 pytz-2020.5 six-1.15.0
WARNING: You are using pip version 20.2.3; however, version 20.3.3 is available.
You should consider upgrading via the 'C:\Users\rober\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe -m pip install --upgrade pip' command.

C:\Users\rober>pip install pandas_datareader
Collecting pandas_datareader
  Downloading pandas_datareader-0.9.0-py3-none-any.whl (107 kB)
     |████████████████████████████████| 107 kB 3.3 MB/s
Requirement already satisfied: pandas>=0.23 in c:\users\rober\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pandas_datareader) (1.2.0)
Collecting requests>=2.19.0
  Downloading requests-2.25.1-py2.py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 1.9 MB/s
Collecting lxml
  Downloading lxml-4.6.2-cp39-cp39-win_amd64.whl (3.5 MB)
     |████████████████████████████████| 3.5 MB 6.8 MB/s
Requirement already satisfied: python-dateutil>=2.7.3 in c:\users\rober\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pandas>=0.23->pandas_datareader) (2.8.1)
Requirement already satisfied: pytz>=2017.3 in c:\users\rober\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pandas>=0.23->pandas_datareader) (2020.5)
Requirement already satisfied: numpy>=1.16.5 in c:\users\rober\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pandas>=0.23->pandas_datareader) (1.19.4)
Collecting certifi>=2017.4.17
  Downloading certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
     |████████████████████████████████| 147 kB 6.8 MB/s
Collecting idna<3,>=2.5
  Downloading idna-2.10-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 161 kB/s
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.2-py2.py3-none-any.whl (136 kB)
     |████████████████████████████████| 136 kB ...
Collecting chardet<5,>=3.0.2
  Downloading chardet-4.0.0-py2.py3-none-any.whl (178 kB)
     |████████████████████████████████| 178 kB 6.4 MB/s
Requirement already satisfied: six>=1.5 in c:\users\rober\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-dateutil>=2.7.3->pandas>=0.23->pandas_datareader) (1.15.0)
Installing collected packages: certifi, idna, urllib3, chardet, requests, lxml, pandas-datareader
  WARNING: The script chardetect.exe is installed in 'C:\Users\rober\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed certifi-2020.12.5 chardet-4.0.0 idna-2.10 lxml-4.6.2 pandas-datareader-0.9.0 requests-2.25.1 urllib3-1.26.2
WARNING: You are using pip version 20.2.3; however, version 20.3.3 is available.
You should consider upgrading via the 'C:\Users\rober\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe -m pip install --upgrade pip' command.

C:\Users\rober>pytho closesAPPL.py
'pytho' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\rober>python closesAPPL.py
Matplotlib is building the font cache; this may take a moment.
Traceback (most recent call last):
  File "C:\Users\rober\closesAPPL.py", line 5, in <module>
    aapl['Close'].plot(grid=True)
NameError: name 'aapl' is not defined

C:\Users\rober>python PYTHON1.PY



*****ACTUALIZACION 2023, FIX 

 

La solución esta aquí

https://stackoverflow.com/questions/71696014/pandas-datareader-not-able-to-pull-from-yahoo-finance-unable-to-read-url-with-r

 

Pandas-datareader not able to pull from yahoo finance- unable to read url with response text in error saying "our engineers are working on it"

Ask Question

Asked 

Modified 9 months ago

Viewed 782 times

1

I was just working on a simple project trying to pull stock data from yahoo finance using pandas-datareader and the code send back an error which I will post below:

pandas_datareader._utils.RemoteDataError: Unable to read URL: https://finance.yahoo.com/quote/AAPL/history?period1=1577869200&period2=1648799999&interval=1d&frequency=1d&filter=history
Response Text:
b'<!DOCTYPE html>\n  <html lang="en-us"><head>\n  <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n      <meta charset="utf-8">\n      <title>Yahoo</title>\n      <meta name="viewport" content="width=device-width,initial-scale=1,minimal-ui">\n      <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">\n      <style>\n  html {\n      height: 100%;\n  }\n  body {\n      background: #fafafc url(https://s.yimg.com/nn/img/sad-panda-201402200631.png) 50% 50%;\n      background-size: cover;\n      height: 100%;\n      text-align: center;\n      font: 300 18px "helvetica neue", helvetica, verdana, tahoma, arial, sans-serif;\n  }\n  table {\n      height: 100%;\n      width: 100%;\n      table-layout: fixed;\n      border-collapse: collapse;\n      border-spacing: 0;\n      border: none;\n  }\n  h1 {\n      font-size: 42px;\n      font-weight: 400;\n      color: #400090;\n  }\n  p {\n      color: #1A1A1A;\n  }\n  #message-1 {\n      font-weight: bold;\n      margin: 0;\n  }\n  #message-2 {\n      display: inline-block;\n      *display: inline;\n      zoom: 1;\n      max-width: 17em;\n      _width: 17em;\n  }\n      </style>\n  <script>\n    document.write(\'<img src="//geo.yahoo.com/b?s=1197757129&t=\'+new Date().getTime()+\'&src=aws&err_url=\'+encodeURIComponent(document.URL)+\'&err=%<pssc>&test=\'+encodeURIComponent(\'%<{Bucket}cqh[:200]>\')+\'" width="0px" height="0px"/>\');var beacon = new Image();beacon.src="//bcn.fp.yahoo.com/p?s=1197757129&t="+new Date().getTime()+"&src=aws&err_url="+encodeURIComponent(document.URL)+"&err=%<pssc>&test="+encodeURIComponent(\'%<{Bucket}cqh[:200]>\');\n  </script>\n  </head>\n  <body>\n  <!-- status code : 404 -->\n  <!-- Not Found on Server -->\n  <table>\n  <tbody><tr>\n      <td>\n      <img src="https://s.yimg.com/rz/p/yahoo_frontpage_en-US_s_f_p_205x58_frontpage.png" alt="Yahoo Logo">\n      <h1 style="margin-top:20px;">Will be right back...</h1>\n      <p id="message-1">Thank you for your patience.</p>\n      <p id="message-2">Our engineers are working quickly to resolve the issue.</p>\n      </td>\n  </tr>\n  </tbody></table>\n  </body></html>'

I looked all over forums to find a solution and saw this was a problem from July of 2021, but I am getting it now. I employed all the solutions, updating my pandas-datareader to make sure it was the right version, even pip uninstalling and pip installing all the packages and libraries again. Nothing seems to be working. No forums solutions work. Oddly enough when I run the scripts through command prompt it works and is able to pull data but not in my IDE which is Visual Studio Code. Does that mean the problem is with Visual Studio Code? Please help as this project is due very soon. I will keep monitoring this post to answer any follow up questions. Thanks!

Improve this question

asked Mar 31, 2022 at 16:21

Jsingh22's user avatar

 

Jsingh22

1111 bronze badge

Add a comment

1 Answer

                                                                        

0

There are fairly recent, open issues in the pandas datareader project regarding this error.

That is, the following snippet yields the observed errors:

from pandas_datareader import data as pdr
data = pdr.get_data_yahoo("SPY", start="2017-01-01", end="2017-04-30")

Here are two solutions. If you want to stick to the pandas datareader, you can try out the code below, which was adapted from this post:

from pandas_datareader import data as pdr
 
import yfinance as yf
yf.pdr_override()
 
# download dataframe using pandas_datareader
data = pdr.get_data_yahoo("SPY", start="2017-01-01", end="2017-04-30")

Or even easier, the pure yfinance version:

import yfinance as yf
data = yf.download("SPY", start="2017-01-01", end="2017-04-30")

Improve this answer

 

 

La solución es

 


 

Aca esta el fix





No hay comentarios:

Publicar un comentario

zen consultora

Blogger Widgets

Entrada destacada

Platzy y el payaso Freddy Vega, PLATZI APESTA, PLATZI NO SIRVE, PLATZI ES UNA ESTAFA

  Platzy y los payasos fredy vega y cvander parte 1,  PLATZI ES UNA ESTAFA Hola amigos, este post va a ir creciendo conforme vaya escribiend...