|  | import streamlit as st | 
					
						
						|  | import pandas as pd | 
					
						
						|  | import plotly.express as px | 
					
						
						|  | from datetime import datetime, date | 
					
						
						|  | from transformers import pipeline | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | classifier = pipeline("zero-shot-classification") | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | st.title("Personal Finance Analysis") | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | st.subheader("Enter Transaction Details:") | 
					
						
						|  | date_input = st.date_input("Date") | 
					
						
						|  | amount = st.number_input("Amount", min_value=0.0) | 
					
						
						|  | category = st.selectbox("Category", ["Groceries", "Rent", "Entertainment", "Utilities", "Other"]) | 
					
						
						|  | description = st.text_input("Description (Optional)") | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | if "monthly_limit" not in st.session_state: | 
					
						
						|  | st.session_state.monthly_limit = 0.0 | 
					
						
						|  | monthly_limit = st.number_input("Set Monthly Spending Limit", min_value=0.0, value=st.session_state.monthly_limit) | 
					
						
						|  | st.session_state.monthly_limit = monthly_limit | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | if st.button("Add Transaction"): | 
					
						
						|  | transaction = {"category": category, "date": str(date_input), "amount": amount, "description": description} | 
					
						
						|  | if "transactions" not in st.session_state: | 
					
						
						|  | st.session_state.transactions = [] | 
					
						
						|  | st.session_state.transactions.append(transaction) | 
					
						
						|  | st.success("Transaction added successfully!") | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | if "transactions" in st.session_state and st.session_state.transactions: | 
					
						
						|  | st.subheader("Transaction History:") | 
					
						
						|  | df = pd.DataFrame(st.session_state.transactions) | 
					
						
						|  | st.dataframe(df) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | st.subheader("Data Analysis:") | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | df['date'] = pd.to_datetime(df['date']) | 
					
						
						|  | df['month'] = df['date'].dt.to_period('M') | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | category_spending = df.groupby("category")["amount"].sum().reset_index() | 
					
						
						|  | fig1 = px.pie(category_spending, values="amount", names="category", title="Spending by Category") | 
					
						
						|  | st.plotly_chart(fig1) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | daily_spending = df.groupby("date")["amount"].sum().reset_index() | 
					
						
						|  | fig2 = px.line(daily_spending, x="date", y="amount", title="Spending Over Time") | 
					
						
						|  | st.plotly_chart(fig2) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | fig3 = px.bar(category_spending, x="category", y="amount", title="Spending by Category (Bar)") | 
					
						
						|  | st.plotly_chart(fig3) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | average_spending = df.groupby('category')['amount'].mean().reset_index() | 
					
						
						|  | fig4 = px.bar(average_spending, x='category', y='amount', title='Average Spending per Category') | 
					
						
						|  | st.plotly_chart(fig4) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | current_month = pd.Timestamp.now().to_period('M') | 
					
						
						|  | monthly_spent = df[df['month'] == current_month]['amount'].sum() | 
					
						
						|  |  | 
					
						
						|  | st.subheader("Monthly Spending Summary") | 
					
						
						|  | st.write(f"Current Month: {current_month}") | 
					
						
						|  | st.write(f"Total Spent This Month: {monthly_spent:.2f}") | 
					
						
						|  | st.write(f"Monthly Limit: {monthly_limit:.2f}") | 
					
						
						|  |  | 
					
						
						|  | if monthly_limit > 0: | 
					
						
						|  | percentage_spent = (monthly_spent / monthly_limit) * 100 | 
					
						
						|  | st.write(f"Percentage of Limit Used: {percentage_spent:.2f}%") | 
					
						
						|  |  | 
					
						
						|  | if monthly_spent > monthly_limit: | 
					
						
						|  | st.warning(f"You have exceeded your monthly spending limit! ({monthly_spent:.2f} / {monthly_limit:.2f})") | 
					
						
						|  | elif percentage_spent > 80: | 
					
						
						|  | st.info("You are approaching your monthly spending limit.") | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | if description: | 
					
						
						|  | candidate_labels = ["positive", "negative", "neutral"] | 
					
						
						|  | classified = classifier(description, candidate_labels) | 
					
						
						|  | st.write("Sentiment Analysis of Description:", classified) |