This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import date, datetime | |
import streamlit as st | |
import pandas as pd | |
import mplfinance as mpf | |
from pandas_datareader import data as pdr | |
@st.experimental_memo(persist='disk') | |
def get_historical_data(symbol, start_date = None): | |
df = pdr.get_data_yahoo(symbol, start=start_date, end=datetime.now()) | |
for col in df.columns: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### **data.py** | |
import streamlit as st | |
import pandas as pd | |
@st.experimental_memo(persist='disk') | |
def csv_to_df(excel_file): | |
df = pd.read_csv(excel_file) | |
return df |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
import pandas_profiling | |
from streamlit_pandas_profiling import st_profile_report | |
import pandas as pd | |
st.set_page_config( | |
page_title='Data Profiler', | |
layout='wide', | |
page_icon='🔍' | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to use: | |
# | |
# [1] Ensure you have `debugpy` installed: | |
# | |
# > pip install debugpy | |
# | |
# [2] In your main streamlit app: | |
# | |
# import streamlit_debug | |
# streamlit_debug.set(flag=True, wait_for_client=True, host='localhost', port=8765) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# It's a bit of a CSS hack but it is possible to get rid of that | |
# large amount of whitespace at the top of Streamlit apps! | |
# | |
# If this hack stops working, it's likely the Streamlit app CSS | |
# classes have changed. Open up dev tools and find the new names | |
# to update the CSS below. :-) | |
# | |
# UPDATED 29/4/2022 with new classes | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
from streamlit_pandas_profiling import st_profile_report | |
from streamlit import session_state as session | |
import numpy as np | |
import pandas as pd | |
from pandas_profiling import ProfileReport | |
if 'data_uploader_submitted' not in session: | |
session.data_uploader_submitted = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ISSUE: Stylistically, I prefer to have a top-level controller and then | |
# form "views" which get laid out on the page in the order they were called. | |
# With just two forms, though, callback chaining is manageable and won’t result in a tangle, | |
# but the layout order is inverted, and in this callbacks solution the profile report and forms | |
# disappear when `cluster_duplicates` is finally called. | |
# | |
# (See this thread: https://discuss.streamlit.io/t/selectbox-bug-on-chaining-forms/19927) | |
# | |
# For a better solution see: multiform_chaining.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Since widgets are created anew on each page their values will be initialized to their default values. | |
# I’ve created a separate ‘value cache’ to store values between pages. | |
# (Note, when a widget has a key and you initialize its value with a session state key value other than the widget’s own key value, | |
# Streamlit will complain. Therefore, the widgets don't have a key.) | |
import streamlit as st | |
# Instantiate the Session State Variables | |
if 'cache' not in st.session_state: | |
st.session_state.cache = {'name': '', 'age': '', 'gender': ''} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
import numpy as np | |
c1, c2 = st.columns([1,1]) | |
show_p1 = c1.checkbox('Show panel 1', True) | |
show_p2 = c2.checkbox('Show panel 2', True) | |
panel1 = c1.empty() | |
panel2 = c2.empty() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
import pandas as pd | |
st.header('Flexible Data Filtering UI') | |
data = [ | |
{ | |
'name':'name1', | |
'nickname':'nickname1', | |
'date':2010, |
OlderNewer