SelmaNajih001 commited on
Commit
9567589
·
verified ·
1 Parent(s): c1f995a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -21,7 +21,7 @@ TICKERS = {
21
  "Apple": "AAPL",
22
  "Facebook": "META",
23
  "Google": "GOOGL",
24
- "NASDAQ": "^IXIC" # indice NASDAQ per confronto aggregato
25
  }
26
 
27
  # --- FETCH STOCK PRICES ROBUSTLY ---
@@ -31,6 +31,10 @@ for company, ticker in TICKERS.items():
31
  end_date = pd.Timestamp.today()
32
  df_prices = yf.download(ticker, start=start_date, end=end_date)
33
 
 
 
 
 
34
  # Ensure 'Close' column exists
35
  if 'Close' not in df_prices.columns:
36
  if 'Adj Close' in df_prices.columns:
 
21
  "Apple": "AAPL",
22
  "Facebook": "META",
23
  "Google": "GOOGL",
24
+ "NASDAQ": "^IXIC"
25
  }
26
 
27
  # --- FETCH STOCK PRICES ROBUSTLY ---
 
31
  end_date = pd.Timestamp.today()
32
  df_prices = yf.download(ticker, start=start_date, end=end_date)
33
 
34
+ # Flatten MultiIndex columns if present
35
+ if isinstance(df_prices.columns, pd.MultiIndex):
36
+ df_prices.columns = ['_'.join([str(c) for c in col]).strip() for col in df_prices.columns]
37
+
38
  # Ensure 'Close' column exists
39
  if 'Close' not in df_prices.columns:
40
  if 'Adj Close' in df_prices.columns: