Geek7 commited on
Commit
16e2221
·
verified ·
1 Parent(s): 1dda37e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -14,12 +14,12 @@ def fetch_stock_data(symbol, start_date, end_date):
14
 
15
  # Function to create features for the model
16
  def create_features(data):
17
- data['Date'] = data.index
18
- data['Year'] = data['Date'].dt.year
19
- data['Month'] = data['Date'].dt.month
20
- data['Day'] = data['Date'].dt.day
21
- data['Hour'] = data['Date'].dt.hour
22
- data['Minute'] = data['Date'].dt.minute
23
 
24
  return data
25
 
@@ -62,7 +62,7 @@ def main():
62
  model = train_model(stock_data)
63
 
64
  # Predict the stock price for a specific date (e.g., the last date in the dataset)
65
- prediction_date = stock_data['Date'].iloc[-1]
66
  prediction_features = [[
67
  prediction_date.year,
68
  prediction_date.month,
 
14
 
15
  # Function to create features for the model
16
  def create_features(data):
17
+ data.index = pd.to_datetime(data.index) # Convert index to datetime
18
+ data['Year'] = data.index.year
19
+ data['Month'] = data.index.month
20
+ data['Day'] = data.index.day
21
+ data['Hour'] = data.index.hour
22
+ data['Minute'] = data.index.minute
23
 
24
  return data
25
 
 
62
  model = train_model(stock_data)
63
 
64
  # Predict the stock price for a specific date (e.g., the last date in the dataset)
65
+ prediction_date = stock_data.index[-1]
66
  prediction_features = [[
67
  prediction_date.year,
68
  prediction_date.month,