-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathst_basic.py
More file actions
157 lines (117 loc) · 4.08 KB
/
st_basic.py
File metadata and controls
157 lines (117 loc) · 4.08 KB
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
import streamlit as st
import pandas as pd
from PIL import Image
st.set_page_config(page_title='Murugavel App')
st.header("STREAMLIT")
st.subheader("Linear Regression")
st.latex("y=mx+c")
st.markdown("_With simple linear regression when we have a single input, we can use statistics to estimate the coefficients. This requires that you calculate statistical properties from the data such as means, standard deviations, correlations and covariance. All of the data must be available to traverse and calculate statistics._")
# we can change the text which we given in the markdown
st.text("Just like a text")
# we cannot change the text which we given in the text
st.caption("Just a caption")
st.code('''for i in range(1,5):
print(vel)''',language="java")
#in the code function we can declare our code
st.markdown("_HOMPRICES DATASET_")
df=pd.read_csv("homeprices.csv")
st.dataframe(df)
# if we use dataset in the dataframe function we select,download
st.text("IN TABLE FORMAT")
st.table(df)
# if we use dataset in the table function we cannnot do anything as we do in the dataframe function
st.markdown("JSON FILE")
json={'a':[1,2,3],'b':[23,2,4]}
st.json(json)
st.markdown("_METRIC_")
col1,col2=st.columns(2)
with col1:
st.metric("AAPL","$40",'+4%')
with col2:
st.metric("ASDF","$203","-43%")
st.markdown("_INPUT WIDGETS_")
submit=st.button("Submit")
# button function is used for the button option in app
if submit:
st.dataframe(df)
st.radio("Choose one:",('a','b','c'))
# radio functio is used for the radio button actions
# if we use button() to get the input from the user then if the click the radio button means the dataframe will disappear
# in that case we use the checkbox()
submit=st.checkbox("Submit")
if submit:
st.dataframe(df)
st.radio("Choose one:",('a','b','c'))
st.markdown("_SELECT BOX_")
cols=list(df.columns)
name=st.selectbox("Choose a feature:",cols)
# selectbox is used for select a option in drop down menu
st.write("The selectd column is :",name)
if name=='price':
st.write(df['price'])
elif name=='area':
st.write(df['area'])
else:
st.write(df['town'])
st.markdown("_NUMBER INPUT_")
col1,col2=st.columns(2)
with col1:
a= st.number_input("Enter a 1st number:")
with col2:
b= st.number_input("Enter a 2nd number:")
submit=st.button('ADD')
if submit:
st.write("The Addition of two numbers is:",a+b)
st.markdown("_SLIDER INPUT_")
col3,col4=st.columns(2)
with col3:
a1= st.slider("Enter a 1st number:")
with col4:
b1= st.slider("Enter a 2nd number:")
submit1=st.checkbox('ADD')
if submit1:
st.write("The Addition of two numbers is:",a1+b1)
st.write("_MULTIPLE SELECTING_")
option=st.multiselect('choose your variable',cols)
st.write('your selection:',option)
st.markdown("_IMAGE SHOWING_")
submit=st.checkbox('show image')
if submit:
img=Image.open("image.jpg")
st.image(img)
st.markdown("_VIDEO SHOWING_")
submit=st.checkbox("show video")
if submit:
vid=open("video.mp4",'rb')
st.video(vid,format='video/mp4')
st.markdown("_AUDIO SHOWING_")
submit=st.checkbox("play audio")
if submit:
aud=open("song.mp3",'rb')
st.audio(aud,format='Audio/mp3')
# graph
# st.markdown("_PLOTLY CHARTS_")
# df1=pd.read_excel("Cotton_Purchase_Details.xlsx")
# st.dataframe(df1.head())
# columns=list(df1.columns)
# target=st.selectbox("Choose a target",columns)
# col2=columns.copy()
# col2.remove(target)
# x_var=st.selectbox("Choose a X variable ",col2)
# y_var=st.selectbox("Choose a y variable ",col2)
# st.markdown("_SCATTER PLOT_")
# fig=px.scatter(df1,x=x_var,y=y_var,color=target)
# st.plotly_chart(fig)
# data=pd.DataFrame(np.random.randn(100,3),columns=['A','B','C'])
# st.markdown("_LINE CHART_")
# st.line_chart(data,use_container_width=True)
# st.markdown("_BAR CHART_")
# st.bar_chart(data,use_container_width=True)
# st.markdown("_AREA CHART_")
# st.area_chart(data,use_container_width=True)
# st.text("STATUS ELEMENTS")
# st.success("This is a success element.")
# st.info("This is a info elements.")
# st.warning("This is a warning element.")
# st.error("This is a error element.")
# st.exception("This is a exception element.")