79458007

Date: 2025-02-21 16:16:32
Score: 0.5
Natty:
Report link

On Github it was pointed out that yfinance has changed the data frame to include MultiIndex parameters. The following code seems to work for me to resolve that.

import pandas as pd
import yfinance as yf
...

            stock = yf.download(Stock,period=ts,actions=True)   #   stock is dataframe used to find stock prices
            if isinstance(stock.columns, pd.MultiIndex):
                stock=stock.xs(key=Stock, axis=1, level=1)  # Extract relevant ticker's data
...

The only other issue I found was when looking at the market at 2 minute intervals the time was given in GMT so I had to subtract a couple hours for my time zone.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: DirtFarmer