-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintro.py
226 lines (117 loc) · 3.94 KB
/
intro.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
import streamlit as st
#Set title
st.title("Intro to streamlit")
from PIL import Image
st.subheader('TECHY')
image=Image.open("Techy.jfif")
st.image(image,use_column_width=True)
# st.write("writing a text here")
# st.markdown("this is a markdown cell")
# st.success("Congrat you run the App successfully")
# st.info("this is an information for you")
# st.warning("Be cautious")
# st.error("Oops you run into an error, you need to rerun your app again or unstall and install your App again")
# st.help(range)
import numpy as np
import pandas as pd
dataframe=np.random.rand(10,20)
st.dataframe(dataframe)
st.text("---"*100)
#<===================>
df=pd.DataFrame(np.random.rand(10,20), columns=('col %d' % i for i in range(20)))
st.dataframe(df.style.highlight_max(axis=1))
st.text("---"*100)
#<===================>
#Display chart
chart_data=pd.DataFrame(np.random.randn(20,3), columns=['a','b','c'])
st.line_chart(chart_data)
st.text("---"*100)
#<===================>
st.area_chart(chart_data)
chart_data=pd.DataFrame(np.random.randn(50,3), columns=['a','b','c'])
st.bar_chart(chart_data)
st.text("---"*100)
#<===================>
import matplotlib.pyplot as plt
arr=np.random.normal(1,1,size=100)
plt.hist(arr,bins=20)
st.pyplot()
st.text("---"*100)
#<===================>
import plotly as plotly
import plotly.figure_factory as ff
#Adding distplot
x1=np.random.randn(200)-2
x2=np.random.randn(200)
x3=np.random.randn(200)-2
hist_data=[x1,x2,x3]
group_labels=['Group1','Group2','Group3']
fig=ff.create_distplot(hist_data,group_labels,bin_size=[.2,.25,.5])
st.plotly_chart(fig,use_container_width=True)
st.text("---"*100)
#<===================>
df=pd.DataFrame(np.random.randn(100,2)/[50,50]+[37.76,-122.4], columns=['lat','lon'])
st.map(df)
st.text("---"*100)
#<===================>
#creating buttons
if st.button("Say hello"):
st.write("hello is here")
else:
st.write("why are you here")
st.text("---"*100)
#<===================>
genre=st.sidebar.radio("What is your favourite genre?", ('Commedy','Drama','Documentary'))
if genre=='Commedy':
st.write("Oh you like Commedy")
elif genre=='Drama':
st.write("Yeah Drama is cool")
else:
st.write(" i see!!")
st.text("---"*100)
#<===================>
#Select button
option=st.selectbox("How was your night?",('Fantastic','Awesome','So-so'))
st.write("Your said your night was:",option)
st.text("---"*100)
#<===================>
option=st.multiselect("How was your night, you can select multiple choice?",('Fantastic','Awesome','So-so'))
st.write("Your said your night was:",option)
st.text("---"*100)
#<===================>
age=st.slider('How old are you?',0,100,18)
st.write("Your age is : ",age)
values=st.slider('Select a range of values',0, 200,(15,80))
st.write('You selected a range between:', values)
number=st.number_input('Input number')
st.write('The number you inputed is:',number)
st.text("---"*100)
st.text("---"*100)
#<===================>
#File uploader
upload_file=st.file_uploader("Choose a csv file", type='csv')
if upload_file is not None:
data=pd.read_csv(pload_file)
st.write(data)
st.success("successfully uploaded")
else:
st.markdown("Please upload a CSV file")
#<===================>
#Color picker
color=st.sidebar.color_picker("Pick your preferred color:",'#00f900')
st.write("This your color:",color)
st.text("---"*100)
st.text("---"*100)
#<===================>
#Side bar
add_sidebar=st.sidebar.selectbox("What is your favourite Sport?",('Football','Basketball','Not sure'))
#<===================>
import time
my_bar=st.progress(0)
for percent_complete in range(100):
time.sleep(0.1)
my_bar.progress(percent_complete+1)
with st.spinner('wait for it...'):
time.sleep(5)
st.success('successful')
st.balloons()