I have a DataFrame
that looks like this:
Date Adj Close Close High ... Low Open Volume
AAPL SPY AAPL SPY AAPL ... AAPL SPY AAPL SPY AAPL SPY
2050 2023-02-28 147.410004 396.260010 147.410004 396.260010 149.080002 ... 146.830002 396.149994 147.050003 397.230011 50547000 96438600
...
How do I get a DataFrame
with just the Close of AAPL and the Close of SPY?
I tried this but I get an error:
column_names = ['Close' + ticker, 'Close SPY']
data = data[column_names]
raise KeyError(f"{keyarr[cmask]} not in index")
KeyError: "['CloseAAPL' 'Close SPY'] not in index"