-
Notifications
You must be signed in to change notification settings - Fork 0
/
introduction.py
168 lines (100 loc) · 3.5 KB
/
introduction.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
import streamlit as st
# Set title
st.title("Our First Streamlit App")
from PIL import Image
image=Image.open("download.png")
st.image(image,use_column_width=True)
st.write("writing a text here")
st.markdown("this is a markdown cell")
st.success("Congrats you run the app successfully")
st.info("This is an information for you")
st.warning("Be cautious")
st.error("Oops you run into the error, you neend to rerun your app 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)
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
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.radio("What is your favourite genre?",("Comedy","Drama","Documentary"))
if genre =="Comedy":
st.write("Oh you like comedy")
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("You 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("You 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("Selct 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 inputted 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(upload_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 is your color:",color)
#Side bar
st.text("----"*100)
st.text("----"*100)
add_sidebar=st.sidebar.selectbox("What is your favourite course?",("A course from TDS on building Data Web App","Others","An 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()