LLMAppp / app.py
Praveen998's picture
Upload folder using huggingface_hub
5e7223c
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.title(" Corona Dashboard")
(
col1,
col2,
) = st.columns(2)
with col1:
option = st.selectbox(" San Francisco", [" San Francisco"])
with col2:
option = st.selectbox(" Monthly / Weekly", [" Monthly ", " Weekly"])
if st.checkbox(" Show raw data"):
st.write("Checkbox checked!")
if st.button(" Visualize"):
st.write("Button clicked!")
st.subheader(" Global Data")
df = pd.read_csv(
"https://raw.githubusercontent.com/plotly/datasets/master/volcano_db.csv",
encoding="iso-8859-1",
)
freq = df
freq = freq.Country.value_counts().reset_index().rename(columns={"count": "x"})
df_v = pd.read_csv(
"https://raw.githubusercontent.com/plotly/datasets/master/volcano.csv"
)
fig = make_subplots(
rows=2,
cols=2,
column_widths=[0.6, 0.4],
row_heights=[0.4, 0.6],
specs=[
[{"type": "scattergeo", "rowspan": 2}, {"type": "bar"}],
[None, {"type": "surface"}],
],
)
fig.add_trace(
go.Scattergeo(
lat=df["Latitude"],
lon=df["Longitude"],
mode="markers",
hoverinfo="text",
showlegend=False,
marker=dict(color="crimson", size=4, opacity=0.8),
),
row=1,
col=1,
)
fig.add_trace(
go.Bar(
x=freq["x"][0:10],
y=freq["Country"][0:10],
marker=dict(color="crimson"),
showlegend=False,
),
row=1,
col=2,
)
fig.add_trace(go.Surface(z=df_v.values.tolist(), showscale=False), row=2, col=2)
fig.update_geos(
projection_type="orthographic",
landcolor="white",
oceancolor="MidnightBlue",
showocean=True,
lakecolor="LightBlue",
)
fig.update_xaxes(tickangle=45)
fig.update_layout(
template="plotly_dark",
margin=dict(r=10, t=25, b=40, l=60),
annotations=[
dict(
text="Source: NOAA",
showarrow=False,
xref="paper",
yref="paper",
x=0,
y=0,
)
],
)
st.plotly_chart(fig)
(
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:
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)
if __name__ == "__main__":
main()