Esempio n. 1
0
    def test_value_types(self, arg_value, proto_value):
        """Test that it supports different types of values."""
        st.time_input('the label', arg_value)

        c = self.get_delta_from_queue().new_element.time_input
        self.assertEqual(c.label, 'the label')
        self.assertEqual(c.value, proto_value)
Esempio n. 2
0
    def test_just_label(self):
        """Test that it can be called with no value."""
        st.time_input('the label')

        c = self.get_delta_from_queue().new_element.time_input
        self.assertEqual(c.label, 'the label')
        self.assertLessEqual(
            datetime.strptime(c.value, '%H:%M').time(),
            datetime.now().time())
Esempio n. 3
0
    def test_just_label(self):
        """Test that it can be called with no value."""
        st.time_input("the label")

        c = self.get_delta_from_queue().new_element.time_input
        self.assertEqual(c.label, "the label")
        self.assertLessEqual(
            datetime.strptime(c.default, "%H:%M").time(),
            datetime.now().time())
        self.assertEqual(c.disabled, False)
Esempio n. 4
0
    def test_time_input_serde(self):
        time = st.time_input("time", key="time")
        check_roundtrip("time", time)

        time_datetime = st.time_input(
            "datetime",
            value=datetime.now(),
            key="time_datetime",
        )
        check_roundtrip("time_datetime", time_datetime)
Esempio n. 5
0
    def test_inside_column(self):
        """Test that it works correctly inside of a column."""
        col1, col2 = st.columns([3, 2])

        with col1:
            st.time_input("foo")

        all_deltas = self.get_all_deltas_from_queue()

        # 4 elements will be created: 1 horizontal block, 2 columns, 1 widget
        self.assertEqual(len(all_deltas), 4)
        time_input_proto = self.get_delta_from_queue().new_element.time_input

        self.assertEqual(time_input_proto.label, "foo")
Esempio n. 6
0
def main():
    data = pd.read_csv("research-and-development-survey-2019-csv.csv")
    data_1 = pd.read_csv(
        "greenhouse-gas-emissions-by-region-industry-and-household-year-ended-2018-csv.csv"
    )
    st.dataframe(data)
    st.table(data.iloc[0:10])

    st.dataframe(data_1)
    st.table(data_1.iloc[0:10])
    st.line_chart(data_1)

    st.json({'foo': 'bar', 'fu': 'ba'})
    st.beta_container()
    st.beta_columns(4)
    col1, col2 = st.beta_columns(2)
    col1.subheader('Columnisation')
    st.beta_expander('Expander')
    with st.beta_expander('Expand'):
        st.write('Juicy deets')

    st.sidebar.write("# Noniot")
    a = st.sidebar.radio('R:', [1, 2])
    st.button('Hit me')
    st.checkbox('Check me out')
    st.radio('Radio', [1, 2, 3])
    st.selectbox('Select', [1, 2, 3])
    st.multiselect('Multiselect', [1, 2, 3])
    st.slider('Slide me', min_value=0, max_value=10)
    st.select_slider('Slide to select', options=[1, '2'])
    st.text_input('Enter some text')
    st.number_input('Enter a number')
    st.text_area('Area for textual entry')
    st.date_input('Date input')
    st.time_input('Time entry')
    st.file_uploader('File uploader')
    st.color_picker('Pick a color')

    st.progress(90)
    st.spinner()
    with st.spinner(text='In progress'):
        time.sleep(5)
        st.success('Done')
    st.balloons()
    st.error('Error message')
    st.warning('Warning message')
    st.info('Info message')
    st.success('Success message')
    st.exception("e")
Esempio n. 7
0
def show_misc_widgets() -> None:
    st.header("Misc widgets")
    st.subheader("Date input")
    with st.echo():
        date = st.date_input("What day is today?")
        st.write(f"Today is {date}")

    st.markdown("------")
    st.subheader("Time input")
    with st.echo():
        time = st.time_input("What time is it?")
        st.write(f"Currently it is {time}")

    st.markdown("------")
    st.subheader("File Uploader")
    st.write(
        "This widget is useful for deployed ML apps hosted on a remote server. "
        "Default limit of uploaded file is 200MB, but the limit can be adjusted using `server.maxUploadSize`"
    )
    with st.echo():
        csv = st.file_uploader("Please choose a CSV file",
                               type="csv",
                               encoding="utf-8")
        if csv is not None:
            df = pd.read_csv(csv)
            st.write(df)
Esempio n. 8
0
def main():

    fname = st.text_input('이름을 입력하세요')
    st.title(fname)

    fname2 = st.text_input('이름을 입력하세요',
                           max_chars=5)  # 유저한테 입력 받을 껀데 5글자까지만 나오게해라
    st.title(fname2)
    #text 해도됨 day01에서 했음

    message = st.text_area('메세지를 입력하세요', height=3)  # 문자를 3줄 까지 입력가능
    st.write(message)

    number = st.number_input('숫자 입력', 1, 100)  # 1부터 100까지 정수로 입력받을수 있음
    st.write(number)

    number2 = st.number_input('숫자입력', 0.0,
                              20.0)  # 0.0 부터 20.0 까지  # 아무것도 안쓰면 실수로 자동
    st.write(number2)

    my_date = st.date_input('약속 날짜')  # 날짜 선택 가능
    st.write(my_date)

    my_time = st.time_input('시간 선택')  # 시간 선택 가능
    st.write(my_time)

    password = st.text_input('비밀번호 입력', type='password',
                             max_chars=12)  # 타입 파라미터 뭐있는지 확인해
    st.write(password)  # 비밀번호 입력할수있게 함  12 글자 까지만

    color = st.color_picker('색을 선택하세요')  # 색깔 선택하기
    st.write(color)
Esempio n. 9
0
def render():
    height = ''
    weight = ''

    st.text_input(label='Пульс утром в покое', value=height)
    st.date_input(label='Дата тренировки')
    st.text_input(label='Количество тренировок', value=weight)
    st.time_input(label='Время начала основной тренировки')
    st.text_input(label='Продолжительность тренировки', value=weight)
    st.selectbox(
        'Направленность',
        ('', 'Силовая', 'Скоростно-силовая', 'Специяльная выносливость',
         'Общая выносливость', 'ОФП', 'Техническая'))

    if st.button('Сохранить'):
        st.write('Сохранено')
    def Sygeplejerske_navn_tid_validering(Sygeplejerske_navn_destination,
                                          Sygeplejerske_tid_destination,
                                          Input_tekst, df, df_st):
        """
        Function:   Makes input fields for nurces when signing for medication with thier name and time of administration.
                    Saves the input to the Excel dataark

        Input:
            [str]	A string containing the distination in the Excel dataark for the name of the nurse for the relevent dosis 
            [str]	A string containing the distination in the Excel dataark for the time of for the relevent dosis 
            [str]	A string containing the text for the input fields and the save button
            [pandas.dataframe]  The dataframe for the main file
            [pandas.dataframe]  The dataframe for the st file

        Output:
            [str]	"Behandlingsdata er gemt"
        """

        # If the variable already has a value, the value is displayed. Otherwise a new value can be given or an old updated.
        Sygeplejerske_navn_værdi = st.text_input(
            Input_tekst + " af sygeplejerske:",
            value=df[Sygeplejerske_navn_destination][
                df_st["selected_treatment"][0]])

        # If the variable already has a value, the value is displayed. Otherwise a new value can be given or an old updated.
        tid = df[Sygeplejerske_tid_destination][df_st["selected_treatment"][0]]
        if tid == "":
            Sygeplejerske_tid_værdi = st.time_input(Input_tekst +
                                                    " til tidspunktet:")
        if tid != "":
            Sygeplejerske_tid_værdi = st.time_input(
                Input_tekst + " til tidspunktet:",
                dt.time(int(tid[0:2]), int(tid[3:5])), int(tid[6:8]))

        # Button for saving input for nurse and time to excel
        if st.button("Gem behandlingsdata for: " + Input_tekst):
            df.loc[df_st["selected_treatment"][0],
                   Sygeplejerske_navn_destination] = Sygeplejerske_navn_værdi
            df.loc[df_st["selected_treatment"][0],
                   Sygeplejerske_tid_destination] = Sygeplejerske_tid_værdi
            df.to_excel(Destination_main_file)
            st.write("Behandlingsdata er gemt")
def main():

    st.title('Smart Traffic System :sunglasses:')
    input_date = st.date_input('Pick a date', value = datetime.datetime(2019, 1, 1),\
                               min_value = datetime.datetime(2019, 1, 1), \
                               max_value = datetime.datetime(2020, 1, 1))
    input_time = st.time_input('Pick a time', value=datetime.time(0, 0))
    Manhattan_geo = get_geo()
    Manhattan_map = get_map(Manhattan_geo, input_date, input_time)
    #     Manhattan_map.save('map.html')
    folium_static(Manhattan_map)
Esempio n. 12
0
def main():
    st.markdown("# Data visualization tool using Streamlit")

    st.title('My first app')

    st.text('Fixed width text')
    st.markdown('_Markdown_') # see *
    st.latex(r''' e^{i\pi} + 1 = 0 ''')
    st.write('Most objects') # df, err, func, keras!
    st.write(['st', 'is <', 3]) # see *
    st.title('My title')
    st.header('My header')
    st.subheader('My sub')

    st.sidebar.button('Hit me')
    st.checkbox('Check me out')
    st.radio('Radio', [1,2,3])
    st.selectbox('Select', [1,2,3])
    st.multiselect('Multiselect', [1,2,3])
    st.slider('Slide me', min_value=0, max_value=10)
    st.select_slider('Slide to select', options=[1,'2'])
    st.text_input('Enter some text')
    st.number_input('Enter a number')
    st.text_area('Area for textual entry')
    st.date_input('Date input')
    st.time_input('Time entry')
    st.file_uploader('File uploader')
    st.color_picker('Pick a color')

    # st.balloons()
    st.error('Error message')
    st.warning('Warning message')
    st.info('Info message')
    st.success('Success message')
    st.spinner()

    option = st.sidebar.selectbox('How would you like to be contacted?', ('Email', 'Home phone', 'Mobile phone'))
    st.sidebar.write('You selected:', option)

    test = st.sidebar.multiselect('Multiselect2', [1,2,3])
    st.sidebar.write('You selected:', test)
Esempio n. 13
0
    def test_duplicate_widget_id_error(self):
        """Multiple widgets with the same key should report an error."""
        widgets = {
            "button":
            lambda key=None: st.button("", key=key),
            "checkbox":
            lambda key=None: st.checkbox("", key=key),
            "multiselect":
            lambda key=None: st.multiselect("", options=[1, 2], key=key),
            "radio":
            lambda key=None: st.radio("", options=[1, 2], key=key),
            "selectbox":
            lambda key=None: st.selectbox("", options=[1, 2], key=key),
            "slider":
            lambda key=None: st.slider("", key=key),
            "text_area":
            lambda key=None: st.text_area("", key=key),
            "text_input":
            lambda key=None: st.text_input("", key=key),
            "time_input":
            lambda key=None: st.time_input("", key=key),
            "date_input":
            lambda key=None: st.date_input("", key=key),
            "number_input":
            lambda key=None: st.number_input("", key=key),
        }

        for widget_type, create_widget in widgets.items():
            create_widget()
            with self.assertRaises(DuplicateWidgetID) as ctx:
                # Test creating a widget with a duplicate auto-generated key
                # raises an exception.
                create_widget()
            self.assertEqual(
                _build_duplicate_widget_message(widget_func_name=widget_type,
                                                user_key=None),
                str(ctx.exception),
            )

        for widget_type, create_widget in widgets.items():
            # widgets with keys are distinct from the unkeyed ones created above
            create_widget(widget_type)
            with self.assertRaises(DuplicateWidgetID) as ctx:
                # Test creating a widget with a duplicate auto-generated key
                # raises an exception.
                create_widget(widget_type)
            self.assertEqual(
                _build_duplicate_widget_message(widget_func_name=widget_type,
                                                user_key=widget_type),
                str(ctx.exception),
            )
Esempio n. 14
0
def main():
    model = joblib.load(open('taxiregressor.pkl', 'rb'))
    st.title('NYC Taxi Fare Predictor')
    passengers = st.selectbox('Number of passengers:', (1, 2, 3, 4, 5, 6))
    distance = st.number_input('Enter trip distance:')
    payment = st.selectbox('Payment Type:', ('Cash', 'Credit'))
    pickup = st.selectbox(
        'Pickup Borough:',
        ('Manhattan', 'Brooklyn', 'Queens', 'Bronx', 'Staten Island'))
    dropoff = st.selectbox(
        'Dropoff Borough:',
        ('Manhattan', 'Brooklyn', 'Queens', 'Bronx', 'Staten Island'))
    weekday = st.selectbox('Day of the week:',
                           ('Monday', 'Tuesday', 'Wednesday', 'Thursday',
                            'Friday', 'Saturday', 'Sunday'))
    temp = st.number_input('Enter temperature:')
    if weekday == 'Monday':
        weekday = 0
    elif weekday == 'Tuesday':
        weekday = 1
    elif weekday == 'Wednesday':
        weekday = 2
    elif weekday == 'Thursday':
        weekday = 3
    elif weekday == 'Friday':
        weekday = 4
    elif weekday == 'Saturday':
        weekday = 5
    elif weekday == 'Sunday':
        weekday = 6

    t = st.time_input('Time:', dt.time(15, 45))
    t = t.hour
    if st.button('Predict'):
        data = [{
            'passenger_count': passengers,
            'trip_distance': distance,
            'payment_type': payment,
            'TripStart_dayofweek': weekday,
            'TripStart_hourofday': t,
            'PickupBorough': pickup,
            'DropoffBorough': dropoff,
            'Avg Temp': temp
        }]
        result = model.predict(pd.DataFrame(data))
        result = str(result)

        st.write('The cost of your ride is estimated to be : ', result)
Esempio n. 15
0
    def test_duplicate_widget_id_error(self):
        """Multiple widgets with the same key should report an error."""
        widgets = {
            "button":
            lambda key=None: st.button("", key=key),
            "checkbox":
            lambda key=None: st.checkbox("", key=key),
            "multiselect":
            lambda key=None: st.multiselect("", options=[1, 2], key=key),
            "radio":
            lambda key=None: st.radio("", options=[1, 2], key=key),
            "selectbox":
            lambda key=None: st.selectbox("", options=[1, 2], key=key),
            "slider":
            lambda key=None: st.slider("", key=key),
            "text_area":
            lambda key=None: st.text_area("", key=key),
            "text_input":
            lambda key=None: st.text_input("", key=key),
            "time_input":
            lambda key=None: st.time_input("", key=key),
            "date_input":
            lambda key=None: st.date_input("", key=key),
            "number_input":
            lambda key=None: st.number_input("", key=key),
        }

        # Iterate each widget type
        for widget_type, create_widget in widgets.items():
            # Test duplicate auto-generated widget key
            create_widget()
            with self.assertRaises(DuplicateWidgetID) as ctx:
                create_widget()
            self.assertEqual(
                _build_duplicate_widget_message(widget_func_name=widget_type,
                                                user_key=None),
                str(ctx.exception),
            )

            # Test duplicate user-specified widget key
            create_widget("key")
            with self.assertRaises(DuplicateWidgetID) as ctx:
                create_widget("key")
            self.assertEqual(
                _build_duplicate_widget_message(widget_func_name=widget_type,
                                                user_key="key"),
                str(ctx.exception),
            )
def main():
    
    # Set up your sidebar here 
    st.sidebar.title("The Sidebar")
    st.sidebar.header("Interactive Widgets:")
    
    button = st.sidebar.button("Button")
    checkbox = st.sidebar.checkbox("Checkbox", value=True)
    radio = st.sidebar.radio("Radio", options=[1, 2, 3], index=2)
    selectbox = st.sidebar.selectbox("Selectbox", options=["a", "b", "c"],
                                     index=1)
    mult_options = ["Hack", "to", "the", "Future"]
    multiselect = st.sidebar.multiselect("Multiselect", options=mult_options,
                                         default=mult_options)
    slider = st.sidebar.slider("Slider", min_value=-10, max_value=10, value=2,
                               step=1)
    select_options = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", 
                      "Friday", "Saturday"]
    select_slider = st.sidebar.select_slider("Select Slider",
        options=select_options, value=("Monday", "Friday"))
    
    
    
    # Set up your page here
    st.title("My Streamlit Application")
    "### _This_ is a 'magic' command using **markdown!**"
    content_spot = st.empty()
    st.header("More Interactive Widgets")
    
    
    text_input = st.text_input("Text Input")
    number_input = st.number_input("Number Input", value=0.75, min_value=0.0,
                                   max_value=1.0)
    text_area = st.text_area("Text Area", height=100)
    date_input = st.date_input("Date Input")
    time_input = st.time_input("Time Input")
    file_uploader = st.file_uploader("File Uploader")
    color_picker = st.color_picker("Color Picker", value="#C137A2")
    
    
    
    # Add content 
    past_values = cached_function()
    past_values.append(True)
    content_spot.markdown(f"<p style='color: {color_picker};'> You've taken "
                          f"{len(past_values)} actions </p>", 
                          unsafe_allow_html=True)
Esempio n. 17
0
import streamlit as st
import numpy as numpy
import pandas as pd
import requests
'''
# TaxiFareModel front
'''

#key,pickup_datetime,pickup_longitude,pickup_latitude,dropoff_longitude,dropoff_latitude,passenger_count

key = '2015-01-27 13:08:24.0000002'
pickup_date = st.date_input('Date:')
pickup_time = st.time_input('Time:')
pickup_datetime = f"{pickup_date} {pickup_time} UTC"
pickup_longitude = st.number_input('Pickup Longitude:', value=-73.950655)
pickup_latitude = st.number_input('Pickup Latitude:', value=40.783282)
dropoff_longitude = st.number_input('Dropoff Longitude:', value=-73.984365)
dropoff_latitude = st.number_input('Dropoff Latitude:', value=40.769802)
passenger_count = st.number_input('Number of Passengers:',
                                  min_value=1,
                                  max_value=8,
                                  step=1,
                                  value=1)

input_data = {
    "dropoff_latitude": [dropoff_latitude],
    "dropoff_longitude": [dropoff_longitude],
    "key": [key],
    "passenger_count": [passenger_count],
    "pickup_datetime": [pickup_datetime],
    "pickup_latitude": [pickup_latitude],
Esempio n. 18
0
if st.button("Submit", key='first_name'):
    result = first_name.title()
    st.success(result)

# Text Area
message = st.text_area("메세지를 입력하세요.", "Type Here ...")
if st.button("Submit", key='message'):
    result = message.title()
    st.success(result)

st.markdown("* * *")

## Date Input
import datetime
today = st.date_input("날짜를 선택하세요.", datetime.datetime.now())
the_time = st.time_input("시간을 입력하세요.", datetime.time())

st.markdown("* * *")

# Display Raw Code - one line
st.subheader("Display one-line code")
st.code("import numpy as np")

# Display Raw Code - snippet
st.subheader("Display code snippet")
with st.echo():
    # 여기서부터 아래의 코드를 출력합니다.
    import pandas as pd
    df = pd.DataFrame()

## Display JSON
Esempio n. 19
0
    st.text("Streamlit is cool")

# firstname = st.text_input("Enter you firstname", "type here.. ")
# if st.button("Submit"):
#     result = firstname.title()
#     st.success(result)

message = st.text_area("Enter you firstname", "type here.. ")
if st.button("Submit"):
    result = message.title()
    st.success(result)

import datetime
today = st.date_input("Today is", datetime.datetime.now())

the_time = st.time_input("The time is ", datetime.time())

st.text("Display JSON")
st.json({'name': "Jesse", 'gender': 'male'})

st.text("Display Raw Code")
st.code("Import numpy as np")

with st.echo():
    import pandas as pd
    df = pd.DataFrame()

import time
my_bar = st.progress(0)

for p in range(100):
Esempio n. 20
0
import streamlit as st
from datetime import datetime

default_tooltip = """
This is a really long tooltip.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut turpis vitae
justo ornare venenatis a vitae leo. Donec mollis ornare ante, eu ultricies
tellus ornare eu. Donec eros risus, ultrices ut eleifend vel, auctor eu turpis.
In consectetur erat vel ante accumsan, a egestas urna aliquet. Nullam eget
sapien eget diam euismod eleifend. Nulla purus enim, finibus ut velit eu,
malesuada dictum nulla. In non arcu et risus maximus fermentum eget nec ante.
""".strip()

st.text_input("some input text", "default text", help=default_tooltip)
st.number_input("number input", value=1, help=default_tooltip)
st.checkbox("some checkbox", help=default_tooltip)
st.radio("best animal", ("tiger", "giraffe", "bear"), 0, help=default_tooltip)
st.button("some button", help=default_tooltip)
st.selectbox("selectbox", ("a", "b", "c"), 0, help=default_tooltip)
st.time_input("time", datetime(2019, 7, 6, 21, 15), help=default_tooltip)
st.date_input("date", datetime(2019, 7, 6, 21, 15), help=default_tooltip)
st.slider("slider", 0, 100, 50, help=default_tooltip)
st.color_picker("color picker", help=default_tooltip)
st.file_uploader("file uploader", help=default_tooltip)
st.multiselect("multiselect", ["a", "b", "c"], ["a", "b"],
               help=default_tooltip)
st.text_area("textarea", help=default_tooltip)
st.select_slider("selectslider", options=["a", "b", "c"], help=default_tooltip)
Esempio n. 21
0
#''')

# Here we would like to add some controllers in order to ask the user to select the parameters of the ride

# 1. Let's ask for:
# - date and time
# - pickup longitude
# - pickup latitude
# - dropoff longitude
# - dropoff latitude
# - passenger count

import datetime

d = st.date_input("When are you going to travel?", datetime.date(2019, 7, 6))
t = st.time_input('What time are you going to travel?', datetime.time(8, 45))
pickup_datetime = f'{d}%20{t}%20UTC'

st.write(pickup_datetime)
st.write('Your are going to travel on:', d, t)

pickup_longitude = st.number_input('Please insert your pickup longitude')
pickup_latitude = st.number_input('Please insert your pickup latitude')
dropoff_longitude = st.number_input('Please insert your dropoff longitude')
dropoff_latitude = st.number_input('Please insert your dropoff latitude')
st.write('Your pickup coordinates are: ', pickup_longitude, pickup_latitude)
st.write('Your dropoff coordinates are: ', dropoff_longitude, dropoff_latitude)

passenger_count = st.number_input('How many people are going to travel?')
st.write(passenger_count, 'passenger')
if st.button('Enviar'):
    resultado = texto.title()
    st.success(resultado)

# Area de texto
mensagem = st.text_area('Entre com sua mensagem: ', 'Digite..')
if st.button('Envie'):
    resultado1 = mensagem.title()
    st.success(resultado1)

# Entrando com datas
import datetime
hoje = st.date_input('Hoje é: ', datetime.datetime.now())

# Horario
agora = st.time_input('Agora é: ', datetime.time())

# Exibindo JSON
st.text('Exibindo um JSON')
st.json({
    'nome': 'Jose Rocha',
    'idade': '54 anos',
    'ocupação': 'analista de suporte'
})

# Exibindo raw code
st.text('Exibindo linhas de código(raw code)')
st.code('import pandas as pd')

# Exibindo raw code
st.text('Exibindo linhas de código(raw code)')
Esempio n. 23
0
#select box
option = st.selectbox("Please select in selctbox!", ("hm", "hi", "kk"))
st.write("option is", option)
#Multiple box
multi_option = st.multiselect("Please select multi box", ("a", "b", "c"))
st.write("you selected", multi_option)

#slider
values = st.slider('Select a range of values', 0.0, 100.0, (25.0, 75.0))
st.write('Values:', values)

# Text input
st.text_input("Enter the input")

# If you want μ•”ν˜Έν™”
st.text_input("Enter the input", type="password")

# Number data
# default value second input args
st.number_input("Enter the number", 0)

# Multi input text
st.text_area("Enter the multi text", "hello")

# Enter the date
st.date_input("data")

# Enter the time
st.time_input("Time")
Esempio n. 24
0
import datetime
import pandas as pd
import numpy as np
import requests

st.markdown('''# NY Taxi
## This tool was created to help you calculate how much your taxi fare will be
### Please, select your parameters for our calculation:
''')

key = 42

d = st.date_input("Choose a date", datetime.date(2021, 3, 12))
st.write('You chose:', d)

t = st.time_input('Choose a time', datetime.time(8, 45))

date_time = datetime.datetime.combine(d, t).strftime("%Y-%m-%d %H:%M:%S UTC")

st.write('You chose', t)

st.markdown('''
### Pickup and dropoff coordinates:
''')

pickup_lon = st.number_input('Insert the pickup longitude')
st.write('The pickup longitude is ', pickup_lon)

pickup_lat = st.number_input('Insert the pickup latitude')
st.write('The pickup latitude is ', pickup_lat)
Esempio n. 25
0
coluna = st.multiselect('Colunas', df.columns)
st.multiselect('Valores', df.values[1])

texto = st.text_input('Altura', '200')
texto = st.slider('Slide me', min_value=100, max_value=600)
st.bar_chart(df, 100, int(texto))

progress = st.slider('Progresso', min_value=1, max_value=100)
st.progress(progress)
if progress == 100:
    st.spinner()
    with st.spinner(text='Corrida...'):
        time.sleep(5)
        st.success('Terminou')
        st.balloons()

    st.color_picker('Aquarela')

st.button('Hit me')
st.checkbox('Check me out')
st.radio('Radio', [1, 2, 3])
st.selectbox('Select', [1, 2, 3])
st.multiselect('Multiselect', [1, 2, 3])
st.select_slider('Slide to select', options=[1, '2'])
st.text_input('Enter some text')
st.number_input('Enter a number')
st.text_area('Area for textual entry')
st.date_input('Date input')
st.time_input('Time entry')
Esempio n. 26
0
'''
### Slider

Membuat slider sederhana menggunakan st.slider
'''

nilai_slider = st.slider('Pilih angka menggunakan slider',
                         min_value=0,
                         max_value=10,
                         value=2)

st.write('Nilai dari slider : ', nilai_slider)
'''
### Date Input

Membuat input tanggal sederhana menggunakan st.date_input
'''

nilai_tanggal = st.date_input('Pilih tanggal menggunakan slider')

st.write('tanggal yang Anda pilih : ', nilai_tanggal)
'''
### Time Input

Membuat input waktu sederhana menggunakan st.time_input
'''

nilai_waktu = st.time_input('Pilih waktu menggunakan slider')

st.write('waktu yang Anda pilih : ', nilai_waktu)
Esempio n. 27
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import streamlit as st
from datetime import time
from datetime import date

options = ('female', 'male')

w1 = st.checkbox('I am human', True)

w2 = st.slider('Age', 0, 100, 25, 1)
st.write('Value 1:', w2)

w3 = st.text_area('Comments', 'Streamlit is awesomeness!')

w4 = st.button('Click me')

w5 = st.radio('Gender', options, 1)

w6 = st.text_input('Text input widget', 'i iz input')

w7 = st.selectbox('Options', options, 1)

w8 = st.time_input('Set an alarm for', time(8, 45))

w9 = st.date_input('A date to celebrate', date(2019, 7, 6))
Esempio n. 28
0
import streamlit as st
from datetime import datetime
from datetime import time

w1 = st.time_input('Label 1', time(8, 45))
st.write('Value 1:', w1)

w2 = st.time_input('Label 2', datetime(2019, 7, 6, 21, 15))
st.write('Value 2:', w2)
Esempio n. 29
0
''')
'''
## Here we would like to add some controllers in order to ask the user to select the parameters of the ride

1. Let's ask for:
- date and time
- pickup longitude
- pickup latitude
- dropoff longitude
- dropoff latitude
- passenger count
'''

date = st.date_input('Date of the ride',
                     value=datetime.datetime(2012, 10, 6, 12, 10, 20))
time = st.time_input('Time of the ride',
                     value=datetime.datetime(2012, 10, 6, 12, 10, 20))
temp_datetime = datetime.datetime.combine(date, time)
pickup_datetime = f"{temp_datetime} UTC"
st.write('The pickup datetime is', pickup_datetime)

pickup_longitude = st.number_input('Pickup longitude', value=40.7614327)
pickup_latitude = st.number_input('Pickup latitude', value=-73.9798156)
dropoff_longitude = st.number_input('Dropoff longitude', value=40.6513111)
dropoff_latitude = st.number_input('Dropoff latitude', value=-73.8803331)
passenger_count = st.number_input('Number of passenger', value=2)
key = '2012-10-06 12:10:20.0000001'
'''
## Once we have these, let's call our API in order to retrieve a prediction

See ? No need to load a `model.joblib` file in this app, we do not even need to know anything about Data Science in order to retrieve a prediction...
Esempio n. 30
0
def main():
    st.subheader('Author: Maaz Ansari')
    st.title("Flight Price Prediction")

    #     html_temp = """
    #     <div style="background-color:#025246 ;padding:10px">
    #     <h2 style="color:white;text-align:center;">Author: Maaz Ansari </h2>
    #     </div>
    #     """
    #     st.markdown(html_temp, unsafe_allow_html=True)

    today = datetime.date.today()
    tomorrow = today + datetime.timedelta(days=1)
    #Date_of_Journey = st.text_input("Date of Your Journey","24/04/2019")
    Date_of_Journey = st.date_input("Date of Your Journey", today)

    Journey_day = pd.to_datetime(Date_of_Journey, format="%Y/%m/%d").day
    Journey_month = pd.to_datetime(Date_of_Journey, format="%Y/%m/%d").month

    #Journey_day = pd.to_datetime(Date_of_Journey, format="%d/%m/%Y").day
    #Journey_month = pd.to_datetime(Date_of_Journey, format = "%d/%m/%Y").month

    Dep_Time = st.time_input("Departure Time", datetime.time(8, 45))
    Dep_hour = Dep_Time.hour
    Dep_min = Dep_Time.minute

    not_needed = st.date_input("Return Date", tomorrow)

    if Date_of_Journey > not_needed:
        st.error('Error: Return Date must fall after Date of your Journey.')

    Arr_Time = st.time_input("Arrival Time", datetime.time(10, 40))
    Arrival_hour = Arr_Time.hour
    Arrival_min = Arr_Time.minute

    #     Dep_Time = st.text_input("Dep_Time","01:10")
    #     Dep_hour = pd.to_datetime(Dep_Time).hour
    #     Dep_min = pd.to_datetime(Dep_Time).minute

    #     Arr_Time = st.text_input("Arr_Time","06:20")
    #     Arrival_hour = pd.to_datetime(Arr_Time).hour
    #     Arrival_min = pd.to_datetime(Arr_Time).minute

    airline = st.selectbox(
        'Airline',
        ('Jet Airways', "IndiGo", "Air India", "Multiple carriers", "SpiceJet",
         "Vistara", "Air Asia", "GoAir", "Multiple carriers Premium economy",
         "Jet Airways Business", "Vistara Premium economy", "Trujet",
         "Air_Asia"))
    if (airline == 'Jet Airways'):
        Jet_Airways = 1
        IndiGo = 0
        Air_India = 0
        Multiple_carriers = 0
        SpiceJet = 0
        Vistara = 0
        GoAir = 0
        Multiple_carriers_Premium_economy = 0
        Jet_Airways_Business = 0
        Vistara_Premium_economy = 0
        Trujet = 0
        Air_Asia = 0

    elif (airline == 'IndiGo'):
        Jet_Airways = 0
        IndiGo = 1
        Air_India = 0
        Multiple_carriers = 0
        SpiceJet = 0
        Vistara = 0
        GoAir = 0
        Multiple_carriers_Premium_economy = 0
        Jet_Airways_Business = 0
        Vistara_Premium_economy = 0
        Trujet = 0
        Air_Asia = 0

    elif (airline == 'Air India'):
        Jet_Airways = 0
        IndiGo = 0
        Air_India = 1
        Multiple_carriers = 0
        SpiceJet = 0
        Vistara = 0
        GoAir = 0
        Multiple_carriers_Premium_economy = 0
        Jet_Airways_Business = 0
        Vistara_Premium_economy = 0
        Trujet = 0
        Air_Asia = 0

    elif (airline == 'Multiple carriers'):
        Jet_Airways = 0
        IndiGo = 0
        Air_India = 0
        Multiple_carriers = 1
        SpiceJet = 0
        Vistara = 0
        GoAir = 0
        Multiple_carriers_Premium_economy = 0
        Jet_Airways_Business = 0
        Vistara_Premium_economy = 0
        Trujet = 0
        Air_Asia = 0

    elif (airline == 'SpiceJet'):
        Jet_Airways = 0
        IndiGo = 0
        Air_India = 0
        Multiple_carriers = 0
        SpiceJet = 1
        Vistara = 0
        GoAir = 0
        Multiple_carriers_Premium_economy = 0
        Jet_Airways_Business = 0
        Vistara_Premium_economy = 0
        Trujet = 0
        Air_Asia = 0

    elif (airline == 'Vistara'):
        Jet_Airways = 0
        IndiGo = 0
        Air_India = 0
        Multiple_carriers = 0
        SpiceJet = 0
        Vistara = 1
        GoAir = 0
        Multiple_carriers_Premium_economy = 0
        Jet_Airways_Business = 0
        Vistara_Premium_economy = 0
        Trujet = 0
        Air_Asia = 0

    elif (airline == 'GoAir'):
        Jet_Airways = 0
        IndiGo = 0
        Air_India = 0
        Multiple_carriers = 0
        SpiceJet = 0
        Vistara = 0
        GoAir = 1
        Multiple_carriers_Premium_economy = 0
        Jet_Airways_Business = 0
        Vistara_Premium_economy = 0
        Trujet = 0
        Air_Asia = 0

    elif (airline == 'Multiple carriers Premium economy'):
        Jet_Airways = 0
        IndiGo = 0
        Air_India = 0
        Multiple_carriers = 0
        SpiceJet = 0
        Vistara = 0
        GoAir = 0
        Multiple_carriers_Premium_economy = 1
        Jet_Airways_Business = 0
        Vistara_Premium_economy = 0
        Trujet = 0
        Air_Asia = 0

    elif (airline == 'Jet Airways Business'):
        Jet_Airways = 0
        IndiGo = 0
        Air_India = 0
        Multiple_carriers = 0
        SpiceJet = 0
        Vistara = 0
        GoAir = 0
        Multiple_carriers_Premium_economy = 0
        Jet_Airways_Business = 1
        Vistara_Premium_economy = 0
        Trujet = 0
        Air_Asia = 0

    elif (airline == 'Vistara Premium economy'):
        Jet_Airways = 0
        IndiGo = 0
        Air_India = 0
        Multiple_carriers = 0
        SpiceJet = 0
        Vistara = 0
        GoAir = 0
        Multiple_carriers_Premium_economy = 0
        Jet_Airways_Business = 0
        Vistara_Premium_economy = 1
        Trujet = 0
        Air_Asia = 0

    elif (airline == 'Trujet'):
        Jet_Airways = 0
        IndiGo = 0
        Air_India = 0
        Multiple_carriers = 0
        SpiceJet = 0
        Vistara = 0
        GoAir = 0
        Multiple_carriers_Premium_economy = 0
        Jet_Airways_Business = 0
        Vistara_Premium_economy = 0
        Trujet = 1
        Air_Asia = 0

    elif (airline == 'Air Asia'):
        Jet_Airways = 0
        IndiGo = 0
        Air_India = 0
        Multiple_carriers = 0
        SpiceJet = 0
        Vistara = 0
        GoAir = 0
        Multiple_carriers_Premium_economy = 0
        Jet_Airways_Business = 0
        Vistara_Premium_economy = 0
        Trujet = 0
        Air_Asia = 1
    else:
        Jet_Airways = 0
        IndiGo = 0
        Air_India = 0
        Multiple_carriers = 0
        SpiceJet = 0
        Vistara = 0
        GoAir = 0
        Multiple_carriers_Premium_economy = 0
        Jet_Airways_Business = 0
        Vistara_Premium_economy = 0
        Trujet = 0
        Air_Asia = 0

    Source = st.selectbox(
        'Source', ("Mumbai", "Chennai", "Delhi", "Kolkata", "Banglore"))

    if (Source == 'Delhi'):
        s_Delhi = 1
        s_Kolkata = 0
        s_Mumbai = 0
        s_Chennai = 0
        s_Banglore = 0

    elif (Source == 'Kolkata'):
        s_Delhi = 0
        s_Kolkata = 1
        s_Mumbai = 0
        s_Chennai = 0
        s_Banglore = 0

    elif (Source == 'Mumbai'):
        s_Delhi = 0
        s_Kolkata = 0
        s_Mumbai = 1
        s_Chennai = 0
        s_Banglore = 0

    elif (Source == 'Chennai'):
        s_Delhi = 0
        s_Kolkata = 0
        s_Mumbai = 0
        s_Chennai = 1
        s_Banglore = 0

    elif (Source == 'Banglore'):
        s_Delhi = 0
        s_Kolkata = 0
        s_Mumbai = 0
        s_Chennai = 0
        s_Banglore = 1

    else:
        s_Delhi = 0
        s_Kolkata = 0
        s_Mumbai = 0
        s_Chennai = 0
        s_Banglore = 0

    Destination = st.selectbox(
        'Destination', ("Cochin", "Delhi", "Hyderabad", "Kolkata", "Banglore"))
    if (Destination == 'Cochin'):
        d_Cochin = 1
        d_Delhi = 0
        d_Banglore = 0
        d_Hyderabad = 0
        d_Kolkata = 0

    elif (Destination == 'Delhi'):
        d_Cochin = 0
        d_Delhi = 1
        d_Banglore = 0
        d_Hyderabad = 0
        d_Kolkata = 0

    elif (Destination == 'Banglore'):
        d_Cochin = 0
        d_Delhi = 0
        d_Banglore = 1
        d_Hyderabad = 0
        d_Kolkata = 0

    elif (Destination == 'Hyderabad'):
        d_Cochin = 0
        d_Delhi = 0
        d_Banglore = 0
        d_Hyderabad = 1
        d_Kolkata = 0

    elif (Destination == 'Kolkata'):
        d_Cochin = 0
        d_Delhi = 0
        d_Banglore = 0
        d_Hyderabad = 0
        d_Kolkata = 1
    else:
        d_Cochin = 0
        d_Delhi = 0
        d_Banglore = 0
        d_Hyderabad = 0
        d_Kolkata = 0

    Total_Stops = st.selectbox('Total Stops', (0, 1, 2, 3, 4, 5))

    output = ""
    if st.button("Predict"):
        output = predict(Total_Stops, Journey_day, Journey_month, Dep_hour,
                         Dep_min, Arrival_hour, Arrival_min, Air_Asia,
                         Air_India, GoAir, IndiGo, Jet_Airways,
                         Jet_Airways_Business, Multiple_carriers,
                         Multiple_carriers_Premium_economy, SpiceJet, Trujet,
                         Vistara, Vistara_Premium_economy, s_Banglore,
                         s_Chennai, s_Delhi, s_Kolkata, s_Mumbai, d_Banglore,
                         d_Cochin, d_Delhi, d_Hyderabad, d_Kolkata)
        output = round(output[0], 2)
        st.success('The Price is {}'.format(output))
        st.success('Bon Voyage!')
        st.balloons()