-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
47 lines (36 loc) · 1.38 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import streamlit as st
import pandas as pd
import numpy as np
path = './car_data.csv'
car_data = pd.read_csv(path)
filtered_data = car_data
# Codes for Filtering conditions
# 1.a) tect box
car_name = st.sidebar.text_input("Input the car_name you want to lookup")
with st.sidebar:
# 1.b) multiselect
options = st.multiselect(
'Manual and/or Automatic?',
['Manual', 'Automatic']
)
option_list =[]
idx = len(options)
# 1.c ~ 1.d) sliders
selling_price = st.slider('selling_price',0,20, (5,10))
year = st.slider('year',2000,2024, (2001, 2003))
# produce filtered car data
car_name , options, selling_price, year
if len(car_name)>0:
filtered_data = filtered_data[ filtered_data['Car_Name'] == car_name ]
if len(options)>0:
filtered_data = filtered_data[ filtered_data['Transmission'].isin(options) ]
if len(selling_price)>0:
filtered_data = filtered_data[ (filtered_data['Selling_Price'] >= selling_price[0]) & (filtered_data['Selling_Price'] <= selling_price[1]) ]
if len(year)>2000 :
filtered_data = filtered_data[ (filtered_data['Year'] >= year[0]) & (filtered_data['Year'] <= year[1]) ]
# 1.e) submit button
submit = st.button("SUBMIT")
if submit :
st.dataframe(filtered_data)
else :
st.dataframe(car_data)