Spaces:
Runtime error
Runtime error
import pandas as pd | |
import random | |
import streamlit as st | |
df = pd.read_csv('profiles.csv') | |
def match_therapist(new_user_interests, new_user_therapy_goals): | |
""" | |
This function takes a new user's interests and therapy goals and finds a matching therapist from the DataFrame. | |
Args: | |
Take user input of new user's interests (e.g., ['Anxiety', 'Stress']). | |
Take user input of new user's therapy goals (e.g., ['Mindfulness', 'Stress management']). | |
Returns: | |
DataFrame: A DataFrame containing the matched therapist's information (including User_ID, Name, etc.). | |
""" | |
# Find therapists with matching interests | |
matching_interests = df['Interests'].apply(lambda interests: any(interest in new_user_interests for interest in interests.split(','))) | |
therapists_by_interests = df[matching_interests] | |
# Further filter based on matching therapy goals (consider weights for stronger matches) | |
matching_goals = therapists_by_interests['Therapy_Goals'].apply(lambda goals: any(goal in new_user_therapy_goals for goal in goals.split(','))) | |
matched_therapist = therapists_by_interests[matching_goals].iloc[0] # Select first matched therapist (can be enhanced) | |
return matched_therapist | |
# Example usage: | |
# new_user_interests = input('Enter the interest: ') | |
# new_user_therapy_goals = input('Enter the therapy: ') | |
new_user_interests = st.text_area("Enter the interest: ") | |
new_user_therapy_goals = st.text_area("Enter the therapy: ") | |
matched_therapist_df = match_therapist(new_user_interests, new_user_therapy_goals) | |
print(f"Matched user information:\n{matched_therapist_df}") | |