ratio = (df["Adj Close"] / df["Close"]).to_numpy()
Possible Fix:
# Convert columns to numeric, coercing errors to NaN if there are non-numeric values
df["Adj Close"] = pd.to_numeric(df["Adj Close"], errors='coerce')
df["Close"] = pd.to_numeric(df["Close"], errors='coerce')
# Perform the division and convert the result to a NumPy array
ratio = (df["Adj Close"] / df["Close"]).to_numpy()
# Optionally, you could also drop any rows where the conversion resulted in NaN values:
# df.dropna(subset=["Adj Close", "Close"], inplace=True)
First off, awesome library! I am getting a lot of use out of it.
I got the following error when using this library:
Error:
auto_adjust failed with unsupported operand type(s) for /: 'str' and 'float'
Call to reproduce:
I believe the error is coming from here: https://github.com/ranaroussi/yfinance/blob/3fe87cb1326249cb6a2ce33e9e23c5fd564cf54b/yfinance/utils.py#L453
Possible Fix: