CEO_Dashboard / app.py
KunaalNaik's picture
Update app.py
56a29e2 verified
raw
history blame contribute delete
No virus
2.44 kB
import streamlit as st
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# Set page layout to wide
st.set_page_config(layout="wide")
st.title("CEO Dashboard")
# Get Information
df = pd.read_csv("CEO.csv")
# Get Numbers
kpi1_value = df['Overall Revenue Growth'].iloc[-1]
kpi2_value = df['Revenue'].iloc[-1]
kpi3_value = df['Cost'].iloc[-1]
kpi4_value = df['Profit'].iloc[-1]
kpi1_percentage = df['Overall Revenue Growth'].iloc[-1] - df['Overall Revenue Growth'].iloc[-2]
kpi2_percentage = df['Revenue'].iloc[-1]/df['Revenue'].iloc[-2]-1
kpi3_percentage = df['Cost'].iloc[-1]/df['Cost'].iloc[-2]-1
kpi4_percentage = df['Profit'].iloc[-1]/df['Profit'].iloc[-2]-1
# Existing metric cards code
col1, col2, col3, col4 = st.columns(4)
col1.metric("Market Share", kpi1_value, kpi1_percentage)
col2.metric("Revenue", kpi2_value, kpi2_percentage)
col3.metric("Cost", kpi3_value, kpi3_percentage)
col4.metric("Profit", kpi4_value, kpi4_percentage)
# Fake data for the bar charts
data1 = pd.DataFrame({
'QTR': ['Q1', 'Q2', 'Q3', 'Q4'],
'Market Share': np.random.randint(10, 20, size=4)
})
data2 = pd.DataFrame({
'QTR': ['Q1', 'Q2', 'Q3', 'Q4'],
'Market Share': np.random.randint(20, 30, size=4)
})
data3 = pd.DataFrame({
'QTR': ['Q1', 'Q2', 'Q3', 'Q4'],
'Market Share': np.random.randint(30, 40, size=4)
})
data4 = pd.DataFrame({
'QTR': ['Q1', 'Q2', 'Q3', 'Q4'],
'Market Share': np.random.randint(40, 50, size=4)
})
# Reduced height for the bar charts
chart_height = 200
# Creating the bar charts
col1, col2 = st.columns(2)
with col1:
st.write("Overall Revenue Growth for the Last 4 Quarters")
# Selecting only the last 4 quarters (assuming df is already sorted by time)
last_four_quarters = df.tail(4)
# Plotting with Matplotlib
fig, ax = plt.subplots(figsize=(6, 4)) # Reduced figure size
ax.bar(last_four_quarters['Quarter'], last_four_quarters['Overall Revenue Growth'])
ax.set_ylabel('Overall Revenue Growth (%)')
plt.xticks(rotation=45) # Rotate quarter labels for better readability
st.pyplot(fig)
with col2:
st.write("Kuch tho bhi1")
st.bar_chart(data2.set_index('QTR'), height=chart_height)
col3, col4 = st.columns(2)
with col3:
st.write("Kuch tho bhi1")
st.bar_chart(data3.set_index('QTR'), height=chart_height)
with col4:
st.write("Kuch tho bhi1")
st.bar_chart(data4.set_index('QTR'), height=chart_height)