generating summary of the documents uploaded and creating recommendations especially on financial goals
Drop files here
or click to upload
import streamlit as st
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
# Page config
st.set_page_config(page_title="Financial Goals Summary", layout="wide")
# Title
st.title("Financial Goals Analysis & Recommendations")
# Sidebar for file upload and settings
with st.sidebar:
st.header("Upload Documents")
uploaded_file = st.file_uploader("Upload your financial documents (CSV)", type=['csv'])
# Sample data if no file is uploaded
if uploaded_file is None:
st.info("Using sample data for demonstration")
data = {
'Category': ['Income', 'Expenses', 'Savings', 'Investments', 'Debt'],
'Amount': [5000, 3000, 1000, 500, 1500],
'Target': [6000, 2500, 1500, 1000, 0]
}
df = pd.DataFrame(data)
else:
df = pd.read_csv(uploaded_file)
# Main content
col1, col2 = st.columns([2, 1])
with col1:
st.subheader("Current Financial Overview")
# Create a waterfall chart
fig = go.Figure(go.Waterfall(
name="Financial Flow",
orientation="v",
measure=["relative"] * len(df),
x=df['Category'],
y=df['Amount'],
text=df['Amount'].apply(lambda x: f"${x:,.0f}"),
connector={"line": {"color": "rgb(63, 63, 63)"}},
))
fig.update_layout(title="Financial Flow Analysis", showlegend=False)
st.plotly_chart(fig, use_container_width=True)
# Progress towards goals
st.subheader("Progress Towards Goals")
for idx, row in df.iterrows():
if row['Target'] > 0: # Only show progress for positive targets
progress = (row['Amount'] / row['Target']) * 100
st.metric(
label=f"{row['Category']} Goal",
value=f"${row['Amount']:,.0f}",
delta=f"${row['Target'] - row['Amount']:,.0f} to target"
)
st.progress(min(progress, 100))
with col2:
st.subheader("Recommendations")
# Generate recommendations based on the data
for idx, row in df.iterrows():
if row['Category'] == 'Savings':
if row['Amount'] < row['Target']:
st.warning(f"💰 Increase savings by ${row['Target'] - row['Amount']:,.0f} to reach your target")
else:
st.success("✅ Savings target achieved! Consider increasing your target.")
elif row['Category'] == 'Investments':
if row['Amount'] < row['Target']:
st.info(f"📈 Consider increasing investments by ${row['Target'] - row['Amount']:,.0f}")
else:
st.success("✅ Investment target achieved! Consider diversifying your portfolio.")
elif row['Category'] == 'Debt':
if row['Amount'] > 0:
st.error(f"⚠️ Focus on reducing debt of ${row['Amount']:,.0f}")
st.markdown("""
Consider:
- Debt consolidation
- Creating a debt payoff plan
- Reducing non-essential expenses
""")
# General recommendations
st.markdown("### General Tips")
st.markdown("""
1. Build an emergency fund (3-6 months of expenses)
2. Follow the 50/30/20 budget rule:
- 50% for needs
- 30% for wants
- 20% for savings/investments
3. Review and adjust goals quarterly
4. Consider automation for savings and investments
""")
# Bottom section for detailed analysis
st.subheader("Detailed Financial Analysis")
st.dataframe(df.style.highlight_max(axis=0, color='lightgreen'))
# Add notes and assumptions
st.markdown("---")
st.caption("""
Notes:
- All figures are monthly averages
- Targets are based on recommended financial planning guidelines
- Adjust goals based on your personal circumstances and financial situation
""")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?