samarthv commited on
Commit
e5f4d0a
1 Parent(s): 3d843b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -3,6 +3,8 @@ import pandas as pd
3
  import numpy as np
4
  from sklearn.linear_model import LinearRegression
5
  import matplotlib.pyplot as plt
 
 
6
 
7
  # Remove the Streamlit default layout
8
  st.set_page_config(layout="wide")
@@ -14,8 +16,14 @@ data2 = pd.read_csv('tesla.csv')
14
  # Combine the datasets into a dictionary
15
  datasets = {'Google': data1, 'Tesla': data2}
16
 
 
 
 
 
 
17
  # Get the user's dataset selection
18
- selected_dataset = st.selectbox('Select Stock', list(datasets.keys()), key='dataset_selection')
 
19
 
20
  # Retrieve the selected dataset
21
  selected_data = datasets[selected_dataset]
@@ -58,7 +66,8 @@ axes[2].set_title(f'{selected_dataset} Daily Percentage Change in Stock Prices')
58
  # Add a submit button
59
  if st.button('Submit'):
60
  # Get the updated dataset selection
61
- selected_dataset = st.selectbox('Select Stock', list(datasets.keys()), key='dataset_selection')
 
62
 
63
  # Retrieve the updated dataset
64
  selected_data = datasets[selected_dataset]
 
3
  import numpy as np
4
  from sklearn.linear_model import LinearRegression
5
  import matplotlib.pyplot as plt
6
+ import random
7
+ import string
8
 
9
  # Remove the Streamlit default layout
10
  st.set_page_config(layout="wide")
 
16
  # Combine the datasets into a dictionary
17
  datasets = {'Google': data1, 'Tesla': data2}
18
 
19
+ # Generate a random string for unique key generation
20
+ def random_string(length):
21
+ letters = string.ascii_lowercase
22
+ return ''.join(random.choice(letters) for i in range(length))
23
+
24
  # Get the user's dataset selection
25
+ key = f'dataset_selection_{random_string(5)}'
26
+ selected_dataset = st.selectbox('Select Stock', list(datasets.keys()), key=key)
27
 
28
  # Retrieve the selected dataset
29
  selected_data = datasets[selected_dataset]
 
66
  # Add a submit button
67
  if st.button('Submit'):
68
  # Get the updated dataset selection
69
+ key = f'dataset_selection_{random_string(5)}'
70
+ selected_dataset = st.selectbox('Select Stock', list(datasets.keys()), key=key)
71
 
72
  # Retrieve the updated dataset
73
  selected_data = datasets[selected_dataset]