Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| # Load Hackathon and Team Data | |
| hackathon_csv = "Hackathon_Dataset.csv" | |
| team_csv = "Team_Dataset.csv" | |
| df_hackathons = pd.read_csv(hackathon_csv) | |
| df_teams = pd.read_csv(team_csv) | |
| # Convert Event Date and Registration Deadline to datetime | |
| df_hackathons["Event Date"] = pd.to_datetime(df_hackathons["Event Date"], errors='coerce') | |
| df_hackathons["Registration Deadline"] = pd.to_datetime(df_hackathons["Registration Deadline"], errors='coerce') | |
| # Ensure numerical columns are correctly formatted | |
| if "Prize Pool" in df_hackathons.columns: | |
| df_hackathons.drop(columns=["Prize Pool"], inplace=True) # Remove Prize Pool Column | |
| # Get unique team names | |
| team_list = df_teams["Team Name"].unique() | |
| # Streamlit UI Setup | |
| st.set_page_config(page_title="Hackathon Finder", layout="wide") | |
| # Sidebar - Filters | |
| st.sidebar.header("π Filter Hackathons") | |
| mode = st.sidebar.selectbox("Select Mode", ["All", "Online", "Offline"]) | |
| date_range = st.sidebar.slider("Select Event Date Range", | |
| min_value=df_hackathons["Event Date"].min().date(), | |
| max_value=df_hackathons["Event Date"].max().date(), | |
| value=(df_hackathons["Event Date"].min().date(), df_hackathons["Event Date"].max().date())) | |
| # Sorting Option (Keep only this) | |
| sort_option = st.sidebar.selectbox("Sort Hackathons By:", ["Registration Deadline (Soonest First)"]) | |
| # Team Selection | |
| st.title("π Hackathon Recommendation System") | |
| st.write("**Select your team to find the best hackathons for you!**") | |
| selected_team = st.selectbox("Select Team:", team_list) | |
| # Fetch Skills of Selected Team | |
| team_skills = df_teams[df_teams["Team Name"] == selected_team]["Skills"].tolist() | |
| unique_skills = list(set(skill.strip() for sublist in team_skills for skill in sublist.split(","))) | |
| # Function to Recommend Hackathons | |
| def recommend_hackathons(skills): | |
| recommendations = [] | |
| for _, row in df_hackathons.iterrows(): | |
| required_skills = row["Required Skills"].split(",") | |
| required_skills = [skill.strip().title() for skill in required_skills] | |
| matched_skills = [skill for skill in skills if skill in required_skills] | |
| if matched_skills: | |
| # Apply Filters | |
| if mode != "All" and row["Mode"] != mode: | |
| continue | |
| if not (date_range[0] <= row["Event Date"].date() <= date_range[1]): | |
| continue | |
| recommendations.append({ | |
| "Hackathon Name": row["Hackathon Name"], | |
| "Organizer": row["Organizer"], | |
| "Registration Deadline": row["Registration Deadline"].strftime('%Y-%m-%d'), | |
| }) | |
| # Sorting by Registration Deadline | |
| recommendations.sort(key=lambda x: x["Registration Deadline"]) | |
| return pd.DataFrame(recommendations).head(10) # Show only top 10 results | |
| # Display Recommendations | |
| if unique_skills: | |
| recommendations_df = recommend_hackathons(unique_skills) | |
| if not recommendations_df.empty: | |
| st.success(f"### β Recommended Hackathons for **{selected_team}**") | |
| st.dataframe(recommendations_df) | |
| else: | |
| st.warning("β οΈ No matching hackathons found.") | |
| else: | |
| st.warning("β οΈ No skills found for this team.") | |
| st.markdown("---") | |
| st.write("π― **Built with Streamlit | AI-Powered Hackathon Finder**") | |