Reputation: 9
Here is the code:
import pandas as pd
import pandas_datareader.data as web
import matplotlib.pyplot as plt
start_date = "2020-01-01"
end_date = "2020-12-31"
data = web.DataReader(name="TSLA", data_source='yahoo', start=start_date, end=end_date)
print(data)
close = data['Close']
ax = close.plot(title='Tesla')
ax.set_xlabel('Date')
ax.set_ylabel('Close')
ax.grid()
plt.show()
And this is the error that it returns:
File "F:\anaconda\lib\site-packages\pandas\core\tools\datetimes.py", line 403, in _convert_listlike_datetimes
arg, _ = maybe_convert_dtype(arg, copy=False, tz=timezones.maybe_get_tz(tz))
TypeError: maybe_convert_dtype() got an unexpected keyword argument 'tz'
It should display a graph of the stock.
Upvotes: 0
Views: 1024
Reputation: 11474
Change your code to:
import locale
import numpy as np
import pandas as pd
from pandas_datareader import data as wb
import yfinance as yf
yf.pdr_override()
start_date = "2020-01-01"
end_date = "2020-12-31"
ticker = 'TSLA'
data = pdr.get_data_yahoo(ticker,start=start_date, end=end_date)
print(data)
close = data['Close']
ax = close.plot(title='Tesla')
ax.set_xlabel('Date')
ax.set_ylabel('Close')
ax.grid()
plt.show()
Upvotes: 1