NBA app to visualize points scored by players via heatmap
Drop files here
or click to upload
import streamlit as st
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
st.title("NBA Player Points Heatmap")
# Create sample NBA player data
data = {
'Player': ['LeBron James', 'Stephen Curry', 'Kevin Durant', 'Giannis Antetokounmpo', 'Luka Doncic',
'Joel Embiid', 'Nikola Jokic', 'Jayson Tatum', 'Damian Lillard', 'Ja Morant'],
'Q1_Points': [8, 12, 10, 7, 9, 11, 6, 8, 10, 7],
'Q2_Points': [10, 8, 12, 9, 8, 9, 8, 7, 8, 9],
'Q3_Points': [7, 10, 8, 11, 12, 8, 10, 9, 7, 8],
'Q4_Points': [12, 9, 7, 8, 10, 7, 9, 11, 8, 10]
}
df = pd.DataFrame(data)
# Set Player as index for the heatmap
heatmap_data = df.set_index('Player')[['Q1_Points', 'Q2_Points', 'Q3_Points', 'Q4_Points']]
# Create the heatmap
st.subheader("Points Scored by Quarter")
fig, ax = plt.subplots(figsize=(10, 8))
sns.heatmap(heatmap_data,
annot=True,
cmap='YlOrRd',
fmt='d',
cbar_kws={'label': 'Points'})
plt.ylabel('Players')
plt.xlabel('Quarters')
plt.tight_layout()
# Display the heatmap
st.pyplot(fig)
# Display the raw data
st.subheader("Raw Data")
st.dataframe(df)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?