Skip to content

Instantly share code, notes, and snippets.

View mkhorasani's full-sized avatar

Mohammad Khorasani mkhorasani

View GitHub Profile
if __name__ == '__main__':
#Creating PostgreSQL client
engine = create_engine('postgresql://<username>:<password>@localhost:5432/<database name>')
#Getting session ID
session_id = get_session_id()
#Creating session state tables
engine.execute("CREATE TABLE IF NOT EXISTS %s (size text)" % (session_id))
import streamlit as st
import time
import random
import plotly.express as px
import pandas as pd
placeholder = st.empty()
start_button = st.empty()
def radar_chart():
df = pd.DataFrame(dict(
r=[random.randint(0,22),
random.randint(0,22),
random.randint(0,22),
random.randint(0,22),
random.randint(0,22)],
theta=['processing cost','mechanical properties','chemical stability',
'thermal stability', 'device integration']))
fig = px.line_polar(df, r='r', theta='theta', line_close=True)
if start_button.button('Start',key='start'):
start_button.empty()
if st.button('Stop',key='stop'):
pass
while True:
radar_chart()
time.sleep(0.5)
import pandas as pd
import streamlit as st
import datetime
import re
import base64
def df_filter(message,df):
slider_1, slider_2 = st.slider('%s' % (message),0,len(df)-1,[0,len(df)-1],1)
while len(str(df.iloc[slider_1][1]).replace('.0','')) < 4:
df.iloc[slider_1,1] = '0' + str(df.iloc[slider_1][1]).replace('.0','')
while len(str(df.iloc[slider_2][1]).replace('.0','')) < 4:
df.iloc[slider_2,1] = '0' + str(df.iloc[slider_1][1]).replace('.0','')
def download_csv(name,df):
csv = df.to_csv(index=False)
base = base64.b64encode(csv.encode()).decode()
file = (f'<a href="data:file/csv;base64,{base}" download="%s.csv">Download file</a>' % (name))
return file
if __name__ == '__main__':
df = pd.read_csv('file_path')
st.title('Datetime Filter')
filtered_df = df_filter('Move sliders to filter dataframe',df)
column_1, column_2 = st.beta_columns(2)
with column_1:
import streamlit as st
import pandas as pd
import plotly.express as px
import datetime
import base64