File size: 3,941 Bytes
add7229
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# zodiac_app.py (Streamlit version)
import streamlit as st
import pandas as pd
import datetime
import matplotlib.pyplot as plt
import io

# Data: zodiac signs with date ranges and personality traits
zodiac_traits = {
    'Aries': {'dates': ((3,21), (4,19)), 'traits': ['Courageous', 'Determined', 'Confident', 'Enthusiastic']},
    'Taurus': {'dates': ((4,20), (5,20)), 'traits': ['Reliable', 'Patient', 'Practical', 'Devoted']},
    'Gemini': {'dates': ((5,21), (6,20)), 'traits': ['Gentle', 'Affectionate', 'Curious', 'Adaptable']},
    'Cancer': {'dates': ((6,21), (7,22)), 'traits': ['Tenacious', 'Highly Imaginative', 'Loyal', 'Emotional']},
    'Leo': {'dates': ((7,23), (8,22)), 'traits': ['Creative', 'Passionate', 'Generous', 'Warmhearted']},
    'Virgo': {'dates': ((8,23), (9,22)), 'traits': ['Loyal', 'Analytical', 'Kind', 'Hardworking']},
    'Libra': {'dates': ((9,23), (10,22)), 'traits': ['Cooperative', 'Diplomatic', 'Gracious', 'Fair-minded']},
    'Scorpio': {'dates': ((10,23), (11,21)), 'traits': ['Resourceful', 'Brave', 'Passionate', 'Stubborn']},
    'Sagittarius': {'dates': ((11,22), (12,21)), 'traits': ['Generous', 'Idealistic', 'Great Sense of Humor']},
    'Capricorn': {'dates': ((12,22), (1,19)), 'traits': ['Responsible', 'Disciplined', 'Self-control', 'Good Managers']},
    'Aquarius': {'dates': ((1,20), (2,18)), 'traits': ['Progressive', 'Original', 'Independent', 'Humanitarian']},
    'Pisces': {'dates': ((2,19), (3,20)), 'traits': ['Compassionate', 'Artistic', 'Intuitive', 'Gentle']},
}

# Compatibility scores between signs (1-10)
compatibility = pd.DataFrame(
    data=[
        [5,6,7,4,8,5,6,7,8,5,6,7], # Aries with Aries, Taurus, ... Pisces
        [6,5,6,7,5,8,7,6,5,8,7,6],
        [7,6,5,8,6,7,8,5,6,7,8,5],
        [4,7,8,5,7,6,5,8,7,6,5,8],
        [8,5,6,7,5,7,6,7,5,8,6,7],
        [5,8,7,6,7,5,8,6,7,5,8,6],
        [6,7,8,5,6,8,5,7,6,8,7,5],
        [7,6,5,8,7,6,7,5,8,6,7,6],
        [8,5,6,7,5,7,6,8,5,7,6,8],
        [5,8,7,6,8,5,8,6,7,5,8,6],
        [6,7,8,5,6,8,7,7,6,8,5,7],
        [7,6,5,8,7,6,5,6,8,6,7,5]
    ],
    index=list(zodiac_traits.keys()),
    columns=list(zodiac_traits.keys())
)

# Helper to determine zodiac sign from birthdate
def get_zodiac_sign(month: int, day: int) -> str:
    for sign, info in zodiac_traits.items():
        start, end = info['dates']
        start_month, start_day = start
        end_month, end_day = end
        # handle year wrap for Capricorn
        if start_month == 12:
            if (month == start_month and day >= start_day) or (month == end_month and day <= end_day):
                return sign
        else:
            if (month == start_month and day >= start_day) or (month == end_month and day <= end_day) or (start_month < month < end_month):
                return sign
    return None

# Streamlit UI
st.title('Zodiac App')

# Horoscope Section
st.header('Get Your Horoscope and Personality Traits')

birthdate = st.date_input("Enter your birthdate:")

if birthdate:
    dt = datetime.datetime.strptime(str(birthdate), '%Y-%m-%d')
    sign = get_zodiac_sign(dt.month, dt.day)
    traits = zodiac_traits[sign]['traits']
    st.subheader(f"Your zodiac sign is: {sign}")
    st.write(f"Personality Traits: {', '.join(traits)}")

# Compatibility Section
st.header('Check Compatibility Between Two Zodiac Signs')

sign1 = st.selectbox('Select your sign:', list(zodiac_traits.keys()))
sign2 = st.selectbox('Select partner sign:', list(zodiac_traits.keys()))

if sign1 and sign2:
    score = compatibility.at[sign1, sign2]
    st.subheader(f"Compatibility Score between {sign1} and {sign2}: {score}")
    
    # Plotting Compatibility Chart
    fig, ax = plt.subplots()
    ax.bar([sign1 + " & " + sign2], [score])
    ax.set_ylim(0, 10)
    ax.set_ylabel('Score (1-10)')
    ax.set_title(f'{sign1} & {sign2} Compatibility')
    
    buf = io.BytesIO()
    plt.savefig(buf, format='png')
    buf.seek(0)
    st.image(buf)