-
Notifications
You must be signed in to change notification settings - Fork 0
/
documentacao.py
155 lines (114 loc) Β· 4.41 KB
/
documentacao.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# main concept
# https://docs.streamlit.io/library/get-started/main-concepts
import streamlit as st
import numpy as np
# st. write('bem vindo')
# dataframe = np.random.randn(10,20)
# st.dataframe(dataframe)
import streamlit as st
import numpy as np
import pandas as pd
#highlight nos maiores valores de cada coluna
# dataframe = pd.DataFrame(
# np.random.randn(10, 20),
# columns=('col %d' % i for i in range(20)))
# st.dataframe(dataframe.style.highlight_max(axis=0))
# dataframe = pd.DataFrame(
# np.random.randn(10, 20),
# columns=('col %d' % i for i in range(20)))
# st.table(dataframe)
# chart_data = pd.DataFrame(
# np.random.randn(20, 3),
# columns=['a', 'b', 'c'])
# # st.line_chart(chart_data)
# map_data = pd.DataFrame(
# np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],
# columns=['lat', 'lon'])
# st.map(map_data)
# import streamlit as st
# x = st.slider('x') # π this is a widget
# st.write(x, 'squared is', x * x)
# import time
# 'Starting a long computation...'
# # Add a placeholder
# latest_iteration = st.empty()
# bar = st.progress(0)
# for i in range(100):
# # Update the progress bar with each iteration.
# latest_iteration.text(f'Iteration {i+1}')
# bar.progress(i + 1)
# time.sleep(0.1)
# '...and now we\'re done!'
# import streamlit as st
# import pandas as pd
# import numpy as np
# st.title('Uber pickups in NYC')
# DATE_COLUMN = 'date/time'
# DATA_URL = ('https://s3-us-west-2.amazonaws.com/'
# 'streamlit-demo-data/uber-raw-data-sep14.csv.gz')
# @st.cache_data
# def load_data(nrows):
# data = pd.read_csv(DATA_URL, nrows=nrows)
# lowercase = lambda x: str(x).lower()
# data.rename(lowercase, axis='columns', inplace=True)
# data[DATE_COLUMN] = pd.to_datetime(data[DATE_COLUMN])
# return data
# data_load_state = st.text('Loading data...')
# data = load_data(10000)
# data_load_state.text("Done! (using st.cache_data)")
# if st.checkbox('Show raw data'):
# st.subheader('Raw data')
# st.write(data)
# st.subheader('Number of pickups by hour')
# hist_values = np.histogram(data[DATE_COLUMN].dt.hour, bins=24, range=(0,24))[0]
# st.bar_chart(hist_values)
# # Some number in the range 0-23
# hour_to_filter = st.slider('hour', 0, 23, 17)
# filtered_data = data[data[DATE_COLUMN].dt.hour == hour_to_filter]
# st.subheader('Map of all pickups at %s:00' % hour_to_filter)
# st.map(filtered_data)
# import streamlit as st
# st.set_page_config(
# page_title="Hello",
# page_icon="π",
# )
# st.write("# Welcome to Streamlit! π")
# st.sidebar.success("Select a demo above.")
# st.markdown(
# """
# Streamlit is an open-source app framework built specifically for
# Machine Learning and Data Science projects.
# **π Select a demo from the sidebar** to see some examples
# of what Streamlit can do!
# ### Want to learn more?
# - Check out [streamlit.io](https://streamlit.io)
# - Jump into our [documentation](https://docs.streamlit.io)
# - Ask a question in our [community
# forums](https://discuss.streamlit.io)
# ### See more complex demos
# - Use a neural net to [analyze the Udacity Self-driving Car Image
# Dataset](https://github.com/streamlit/demo-self-driving)
# - Explore a [New York City rideshare dataset](https://github.com/streamlit/demo-uber-nyc-pickups)
# """
# )
# def load_data(url):
# df = pd.read_csv(url) # π Download the data
# return df
# df = load_data("https://github.com/plotly/datasets/raw/master/uber-rides-data1.csv")
# st.dataframe(df)
# st.button("Rerun")
import streamlit as st
import datetime
st.title('Counter Example')
if 'count' not in st.session_state:
st.session_state.count = 0
st.session_state.last_updated = datetime.time(0,0)
def update_counter():
st.session_state.count += st.session_state.increment_value
st.session_state.last_updated = st.session_state.update_time
with st.form(key='my_form'):
st.time_input(label='Enter the time', value=datetime.datetime.now().time(), key='update_time')
st.number_input('Enter a value', value=0, step=1, key='increment_value')
submit = st.form_submit_button(label='Update', on_click=update_counter)
st.write('Current Count = ', st.session_state.count)
st.write('Last Updated = ', st.session_state.last_updated)