test1 / pages /pd.py
dvaz's picture
Update pages/pd.py
e30b335
import pandas as pd
import streamlit as st
import plotly.express as px
st.set_page_config('Dashboard',':bar_chart:',layout='wide')
#st.title=(':bar_chart: Sales Dashboard')
#st.markdown('##')
df= pd.read_excel(
io='pd1.xlsx',
#sheet_name='Ark1',
#skiprows=3,
#usecols='A,C:F',
#nrows=10,
)
#st.dataframe(df)
st.sidebar.header('Please filter here')
city=st.sidebar.multiselect('Select the City:',df['City'].unique(),default=df['City'].unique())
customer_type=st.sidebar.multiselect('Select the customer type:',df['Customer_type'].unique(),default=df['Customer_type'].unique())
gender=st.sidebar.multiselect('Select the Gender:',df['Gender'].unique(),default=df['Gender'].unique())
#Filter
df_selection = df.query(
"City == @city & Customer_type == @customer_type & Gender == @gender"
)
st.dataframe(df_selection)
total=int(df_selection['Total'].sum())
rating=round(df_selection['Rating'].mean(),1)
star=":star:" * int(round(rating,0))
lc,rc =st.columns(2)
with lc:
st.subheader('Total Sales:')
st.subheader(f'$ {total:,}')
with rc:
st.subheader('Average Rating:')
st.subheader(f'{rating} {star}')
st.markdown('---')