Spaces:
Sleeping
Sleeping
import streamlit as st | |
import pandas as pd | |
import numpy as np | |
import yfinance as yf | |
import altair as alt | |
import plotly.figure_factory as ff | |
import pydeck as pdk | |
from vega_datasets import data as vds | |
import plotly.express as px | |
import plotly.graph_objects as go | |
from plotly.subplots import make_subplots | |
from streamlit_image_comparison import image_comparison | |
def on_input_change(): | |
user_input = st.session_state.user_input | |
st.session_state.past.append(user_input) | |
st.session_state.generated.append( | |
{"data": "The messages from Bot\nWith new line", "type": "normal"} | |
) | |
def on_btn_click(): | |
del st.session_state.past[:] | |
del st.session_state.generated[:] | |
def main(): | |
st.write("Hello, world!") | |
st.header(" Al Generated this app - spotify recommendations") | |
st.subheader(" this application contains the auto generated layout") | |
( | |
col1, | |
col2, | |
) = st.columns(2) | |
with col1: | |
st.write("Hello, world!") | |
with col2: | |
option = st.selectbox( | |
" gender / male / female", [" gender ", " male ", " female"] | |
) | |
( | |
col1, | |
col2, | |
) = st.columns(2) | |
with col1: | |
value = st.slider( | |
" max predictions", min_value=0, max_value=100, value=50, key=39 | |
) | |
with col2: | |
value = st.slider( | |
" num categories", min_value=0, max_value=100, value=50, key=81 | |
) | |
( | |
col1, | |
col2, | |
) = st.columns(2) | |
with col1: | |
option = st.radio("Choose an option:", ["Option 1", "Option 2", "Option 3"]) | |
with col2: | |
if st.checkbox("Check me"): | |
st.write("Checkbox checked!") | |
if st.button(" generate recommendations"): | |
st.write("Button clicked!") | |
( | |
col1, | |
col2, | |
) = st.columns(2) | |
with col1: | |
st.table( | |
{ | |
"Country": ["USA", "Canada", "UK", "Australia"], | |
"Population (millions)": [331, 38, 66, 25], | |
"GDP (trillion USD)": [22.675, 1.843, 2.855, 1.488], | |
} | |
) | |
with col2: | |
st.line_chart( | |
pd.DataFrame( | |
{ | |
"Apple": yf.download("AAPL", start="2023-01-01", end="2023-07-31")[ | |
"Adj Close" | |
], | |
"Google": yf.download( | |
"GOOGL", start="2023-01-01", end="2023-07-31" | |
)["Adj Close"], | |
"Microsoft": yf.download( | |
"MSFT", start="2023-01-01", end="2023-07-31" | |
)["Adj Close"], | |
} | |
) | |
) | |
( | |
col1, | |
col2, | |
) = st.columns(2) | |
with col1: | |
data = pd.DataFrame( | |
{"X": [1, 2, 3, 4, 5], "Y1": [10, 16, 8, 14, 12], "Y2": [5, 8, 3, 6, 7]} | |
) | |
st.area_chart(data) | |
with col2: | |
st.bar_chart( | |
pd.DataFrame(np.random.randn(20, 3), columns=["Apple", "Banana", "Cherry"]) | |
) | |
( | |
col1, | |
col2, | |
) = st.columns(2) | |
with col1: | |
st.write("Hello, world!") | |
with col2: | |
df = px.data.gapminder().query("year == 2007").query("continent == 'Americas'") | |
fig = px.pie( | |
df, | |
values="pop", | |
names="country", | |
title="Population of American continent", | |
hover_data=["lifeExp"], | |
labels={"lifeExp": "life expectancy"}, | |
) | |
fig.update_traces(textposition="inside", textinfo="percent+label") | |
st.plotly_chart(fig) | |
source = vds.cars() | |
chart = { | |
"mark": "point", | |
"encoding": { | |
"x": {"field": "Horsepower", "type": "quantitative"}, | |
"y": {"field": "Miles_per_Gallon", "type": "quantitative"}, | |
"color": {"field": "Origin", "type": "nominal"}, | |
"shape": {"field": "Origin", "type": "nominal"}, | |
}, | |
} | |
tab1, tab2 = st.tabs(["Streamlit theme (default)", "Vega-Lite native theme"]) | |
with tab1: | |
st.vega_lite_chart(source, chart, theme="streamlit", use_container_width=True) | |
with tab2: | |
st.vega_lite_chart(source, chart, theme=None, use_container_width=True) | |
( | |
col1, | |
col2, | |
) = st.columns(2) | |
with col1: | |
st.video("https://www.youtube.com/watch?v=50hVvC7gMR8&t=5s", format="video/mp4") | |
with col2: | |
st.image( | |
"https://assets-global.website-files.com/59e16042ec229e00016d3a66/6441d5f76d21e1e4dee9ffa2_Gen%20AI%20blog_Blog%20hero.png", | |
caption="Image Caption", | |
) | |
st.plotly_chart( | |
ff.create_distplot( | |
[np.random.randn(200) - 2, np.random.randn(200), np.random.randn(200) + 2], | |
["Negative Shift", "Normal", "Positive Shift"], | |
bin_size=[0.1, 0.25, 0.5], | |
), | |
use_container_width=True, | |
) | |
st.header(" auto generated by sketch2streamiit") | |
if __name__ == "__main__": | |
main() | |