yfinance icon indicating copy to clipboard operation
yfinance copied to clipboard

yf.Ticker error

Open prRZ5F4LXZ opened this issue 4 years ago • 1 comments

I got the following error. Does anybody know what is wrong with it?

>>> import yfinance as yf
>>> msft = yf.Ticker('MSFT')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/yfinance/base.py", line 65, in __init__
    "yearly": utils.empty_df(),
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/yfinance/utils.py", line 38, in empty_df
    empty = _pd.DataFrame(index=index, data={
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/frame.py", line 411, in __init__
    mgr = init_dict(data, index, columns, dtype=dtype)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/internals/construction.py", line 257, in init_dict
    return arrays_to_mgr(arrays, data_names, index, columns, dtype=dtype)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/internals/construction.py", line 82, in arrays_to_mgr
    arrays = _homogenize(arrays, index, dtype)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/internals/construction.py", line 322, in _homogenize
    val = sanitize_array(
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/internals/construction.py", line 712, in sanitize_array
    subarr = construct_1d_arraylike_from_scalar(value, len(index), dtype)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/dtypes/cast.py", line 1233, in construct_1d_arraylike_from_scalar
    subarr = np.empty(length, dtype=dtype)
TypeError: Cannot interpret '<attribute 'dtype' of 'numpy.generic' objects>' as a data type
>>> data = msft.history(period='max')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'msft' is not defined

prRZ5F4LXZ avatar Jun 15 '21 12:06 prRZ5F4LXZ

Is this fixed?

ValueRaider avatar Jan 06 '23 17:01 ValueRaider