Download tabs/plot_by_columns.py from arash7920/streamlit: direct link, hf CLI and curl.
- Browser
- Download file 2.38 kB
-
https://huggingface.co/spaces/arash7920/streamlit/resolve/main/tabs/plot_by_columns.py
- Command line
-
hf download hf://spaces/arash7920/streamlit/tabs/plot_by_columns.py
-
curl -L -o plot_by_columns.py https://huggingface.co/spaces/arash7920/streamlit/resolve/main/tabs/plot_by_columns.py
2.38 kB
| from tools.ofi_delta import calculate_ofi_and_delta | |
| from utils.plots import plot_multiple_columns | |
| # import streamlit as session | |
| def plot_by_columns(ticker, date, timeframe, session): | |
| session.markdown('### Stock Dataframe') | |
| with session.spinner(text="Downloading required data..."): | |
| df = calculate_ofi_and_delta(ticker=ticker, date=date, timeframe=timeframe) | |
| session.dataframe(df) | |
| session.markdown('### Stock Dataframe Statistics') | |
| session.dataframe(df.describe()) | |
| session.markdown('### Plot By columns') | |
| first_column = session.text_input('Enter the Primary Column Name:') | |
| second_column = session.text_input('Enter the Secondary Column Name:') | |
| third_column_query = session.selectbox("Do you want to have a third column be plotted on your chart?", ("", "Yes", "No")) | |
| if first_column != '' and second_column != '': | |
| if third_column_query == '' or third_column_query == 'No': | |
| plot_figure = plot_multiple_columns(dataframe=df, primary_column=first_column, | |
| secondary_column=second_column) | |
| session.plotly_chart(plot_figure) | |
| else: | |
| third_column = session.text_input('Enter the ternary Column Name:') | |
| scale_query = session.selectbox('Please select the closest column in terms of scale to the third column.', | |
| ('', 'first column', 'second column')) | |
| if third_column != '' and scale_query != '': | |
| if scale_query == 'first column': | |
| plot_figure = plot_multiple_columns(dataframe=df, primary_column=first_column, | |
| secondary_column=second_column, ternary_column=third_column, | |
| scale_similarity=1) | |
| session.plotly_chart(plot_figure) | |
| elif scale_query == 'second column': | |
| plot_figure = plot_multiple_columns(dataframe=df, primary_column=first_column, | |
| secondary_column=second_column, ternary_column=third_column, | |
| scale_similarity=2) | |
| session.plotly_chart(plot_figure) | |
| else: | |
| session.markdown('### You Have Not Chosen Any Columns Yet!') | |