Create an application that displays data organized in 3 columns. Each entry in the columns has an info bubble when hovered with its metadata coming from another source of data. Find the best dataset applicable to biuld this app
Drop files here
or click to upload
import streamlit as st
import pandas as pd
# Page config
st.set_page_config(page_title="Column Data with Hover Info", layout="wide")
# Load sample datasets - using Nobel Prize winners as an example
@st.cache_data
def load_data():
# Main data for columns
winners = pd.read_csv('https://corsproxy.io/?https://raw.githubusercontent.com/datasets/nobel-prize/master/data/nobel.csv')
# Get unique winners from different categories
physics = winners[winners['category'] == 'Physics'].head(5)
chemistry = winners[winners['category'] == 'Chemistry'].head(5)
medicine = winners[winners['category'] == 'Medicine'].head(5)
return physics, chemistry, medicine
# Custom CSS for hover effects
st.markdown("""
<style>
.hover-info {
position: relative;
padding: 10px;
margin: 5px;
border: 1px solid #ddd;
border-radius: 5px;
cursor: help;
}
.hover-info:hover {
background-color: #f0f2f6;
}
</style>
""", unsafe_allow_html=True)
# Load data
physics, chemistry, medicine = load_data()
# Title
st.title("Nobel Prize Winners by Category")
st.write("Hover over each winner to see more details about their achievement")
# Create three columns
col1, col2, col3 = st.columns(3)
# Physics column
with col1:
st.subheader("Physics")
for _, winner in physics.iterrows():
with st.container():
html = f"""
<div class="hover-info" title="Year: {winner['year']}
Prize Share: {winner['prizeShare']}
Motivation: {winner['motivation']}">
{winner['firstname']} {winner['surname']}
</div>
"""
st.markdown(html, unsafe_allow_html=True)
# Chemistry column
with col2:
st.subheader("Chemistry")
for _, winner in chemistry.iterrows():
with st.container():
html = f"""
<div class="hover-info" title="Year: {winner['year']}
Prize Share: {winner['prizeShare']}
Motivation: {winner['motivation']}">
{winner['firstname']} {winner['surname']}
</div>
"""
st.markdown(html, unsafe_allow_html=True)
# Medicine column
with col3:
st.subheader("Medicine")
for _, winner in medicine.iterrows():
with st.container():
html = f"""
<div class="hover-info" title="Year: {winner['year']}
Prize Share: {winner['prizeShare']}
Motivation: {winner['motivation']}">
{winner['firstname']} {winner['surname']}
</div>
"""
st.markdown(html, unsafe_allow_html=True)
# Footer
st.markdown("---")
st.markdown("Data source: Nobel Prize Dataset")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?