Spaces:
Sleeping
Sleeping
Commit
·
26be06c
1
Parent(s):
fc194f7
add available countries and brands
Browse files
app.py
CHANGED
|
@@ -48,8 +48,8 @@ def plot_data(filtered_data):
|
|
| 48 |
def main():
|
| 49 |
st.title("Data Visualization App")
|
| 50 |
|
| 51 |
-
# Step 1: Select Year
|
| 52 |
-
year = st.sidebar.selectbox("Select Year", range(2017, 2022))
|
| 53 |
|
| 54 |
# Load data based on year selection
|
| 55 |
data = load_data(year)
|
|
@@ -57,10 +57,14 @@ def main():
|
|
| 57 |
if data is not None:
|
| 58 |
# Step 2: Select Country based on available options for the year
|
| 59 |
available_countries = data['country'].unique()
|
|
|
|
|
|
|
| 60 |
country = st.sidebar.selectbox("Select Country", available_countries)
|
| 61 |
|
| 62 |
# Step 3: Select Brand based on available options for the year and country
|
| 63 |
available_brands = data[data['country'] == country]['brand'].unique()
|
|
|
|
|
|
|
| 64 |
brand = st.sidebar.selectbox("Select Brand", available_brands)
|
| 65 |
|
| 66 |
# Filter data based on inputs
|
|
|
|
| 48 |
def main():
|
| 49 |
st.title("Data Visualization App")
|
| 50 |
|
| 51 |
+
# Step 1: Select Year, default to 2021
|
| 52 |
+
year = st.sidebar.selectbox("Select Year", range(2017, 2022), index=4)
|
| 53 |
|
| 54 |
# Load data based on year selection
|
| 55 |
data = load_data(year)
|
|
|
|
| 57 |
if data is not None:
|
| 58 |
# Step 2: Select Country based on available options for the year
|
| 59 |
available_countries = data['country'].unique()
|
| 60 |
+
# default to COUNTRY_6B71
|
| 61 |
+
available_countries = ["COUNTRY_6B71"] + list(x for x in available_countries if x != "COUNTRY_6B71")
|
| 62 |
country = st.sidebar.selectbox("Select Country", available_countries)
|
| 63 |
|
| 64 |
# Step 3: Select Brand based on available options for the year and country
|
| 65 |
available_brands = data[data['country'] == country]['brand'].unique()
|
| 66 |
+
# default to BRAND_24CB
|
| 67 |
+
available_brands = ["BRAND_24CB"] + list(x for x in available_brands if x != "BRAND_24CB")
|
| 68 |
brand = st.sidebar.selectbox("Select Brand", available_brands)
|
| 69 |
|
| 70 |
# Filter data based on inputs
|