-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbest_value.py
36 lines (28 loc) · 1.22 KB
/
best_value.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import streamlit as st
import pandas as pd
import plotly.express as px
def app():
st.title("*:green[Top-Rated & Best Value Packs]*")
# Load dataset
df = pd.read_excel('Sims_4_Data_v1.xlsx')
# Data Preprocessing
df['Average Rating'] = pd.to_numeric(df['Average Rating'], errors='coerce')
df['Price'] = pd.to_numeric(df['Origin/ Official Price (USD)'], errors='coerce')
# Calculate "Value Score" (example: rating divided by price)
df['Value Score'] = df['Average Rating'] / df['Price']
# Drop rows with NaN values in the columns used for plotting
df = df.dropna(subset=['Price', 'Average Rating', 'Value Score'])
# Bubble Chart for Best Value Packs
st.subheader("Best Value for Money Packs")
fig = px.scatter(df,
x='Price',
y='Average Rating',
size='Value Score',
color='Type',
hover_name='Title',
title='Best Value for Money DLCs')
st.plotly_chart(fig)
# Bar Chart for Top Rated DLCs
st.subheader("Top-Rated DLCs")
top_rated = df.sort_values(by='Average Rating', ascending=False).head(5)
st.table(top_rated[['Title', 'Average Rating']])