Create a streamlit application that displays 3 drop-boxes for game title, year, and service at the same height on the page. One dumber field to ask for a number value; it can be named PSU in the next line of the page. Add 3 more fields to just display the selection for the drop-box ones. Please add one line graph and a pie chart showing example data.
To upload files, please first save the app
import streamlit as st
import pandas as pd
import plotly.express as px
# Set page title
st.title("Game Statistics Dashboard")
# Create sample data for dropdowns
game_titles = ["The Last of Us", "God of War", "Spider-Man", "Horizon Zero Dawn", "Ghost of Tsushima"]
years = [2018, 2019, 2020, 2021, 2022]
services = ["PlayStation Plus", "Xbox Game Pass", "Nintendo Online", "Steam", "Epic Games"]
# Create three columns for dropdowns
col1, col2, col3 = st.columns(3)
with col1:
selected_game = st.selectbox("Select Game Title", game_titles)
with col2:
selected_year = st.selectbox("Select Year", years)
with col3:
selected_service = st.selectbox("Select Service", services)
# PSU number input
psu_value = st.number_input("Enter PSU Value", min_value=0, max_value=1000, value=500)
# Display selections
st.markdown("### Selected Values")
col4, col5, col6 = st.columns(3)
with col4:
st.write(f"Game: {selected_game}")
with col5:
st.write(f"Year: {selected_year}")
with col6:
st.write(f"Service: {selected_service}")
# Create sample data for charts
line_data = pd.DataFrame({
'Month': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
'Players': [1000, 1200, 950, 1500, 1300, 1800],
'Revenue': [5000, 6000, 4750, 7500, 6500, 9000]
})
pie_data = pd.DataFrame({
'Platform': ['PS5', 'Xbox Series X', 'PC', 'Nintendo Switch'],
'Sales': [35, 25, 30, 10]
})
# Create charts
st.markdown("### Analytics")
col7, col8 = st.columns(2)
with col7:
st.markdown("Monthly Trends")
fig_line = px.line(line_data, x='Month', y=['Players', 'Revenue'],
title='Monthly Players and Revenue')
st.plotly_chart(fig_line, use_container_width=True)
with col8:
st.markdown("Platform Distribution")
fig_pie = px.pie(pie_data, values='Sales', names='Platform',
title='Sales Distribution by Platform')
st.plotly_chart(fig_pie, use_container_width=True)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?