CASAS

import streamlit as st import pandas as pd # --- CONFIGURACIÓN DE PÁGINA --- st.set_page_config(page_title="InmoFinder | Buscador de Propiedades", layout="wide") # --- ESTILOS CSS PERSONALIZADOS (UX) --- st.markdown("""""", unsafe_allow_html=True) # --- FASE 3.1: DEFINICIÓN DE DATOS (MOCK DATA) --- @st.cache_data def get_property_data(): data = [ {"id": 1, "tipo": "Casa", "operacion": "Venta", "habitaciones": 3, "precio": 155000, "barrio": "Funes R", "features": ["Cochera", "Piscina", "Mascotas"], "img": "https://images.unsplash.com/photo-1568605114967-8130f3a36994?w=500"}, {"id": 2, "tipo": "Departamento", "operacion": "Alquiler", "habitaciones": 1, "precio": 45000, "barrio": "Centro", "features": ["Balcón", "Mascotas"], "img": "https://images.unsplash.com/photo-1522708323590-d24dbb6b0267?w=500"}, {"id": 3, "tipo": "Casa", "operacion": "Venta", "habitaciones": 4, "precio": 210000, "barrio": "Aldea", "features": ["Cochera", "Seguridad", "Piscina"], "img": "https://images.unsplash.com/photo-1512917774080-9991f1c4c750?w=500"}, {"id": 4, "tipo": "Departamento", "operacion": "Venta", "habitaciones": 2, "precio": 95000, "barrio": "Pichincha", "features": ["Balcón", "Cochera"], "img": "https://images.unsplash.com/photo-1493809842364-78817add7ffb?w=500"}, {"id": 5, "tipo": "Casa", "operacion": "Alquiler", "habitaciones": 2, "precio": 85000, "barrio": "Funes City", "features": ["Mascotas", "Cochera"], "img": "https://images.unsplash.com/photo-1480074568708-e7b720bb3f09?w=500"}, {"id": 6, "tipo": "Departamento", "operacion": "Alquiler", "habitaciones": 3, "precio": 120000, "barrio": "Puerto Norte", "features": ["Balcón", "Seguridad", "Piscina"], "img": "https://images.unsplash.com/photo-1502672260266-1c1ef2d93688?w=500"}, {"id": 7, "tipo": "Casa", "operacion": "Venta", "habitaciones": 2, "precio": 130000, "barrio": "Fisherton", "features": ["Cochera"], "img": "https://images.unsplash.com/photo-1449844908441-8829872d2607?w=500"}, {"id": 8, "tipo": "Departamento", "operacion": "Venta", "habitaciones": 1, "precio": 65000, "barrio": "Abasto", "features": ["Mascotas"], "img": "https://images.unsplash.com/photo-1505691938895-1758d7feb511?w=500"}, {"id": 9, "tipo": "Casa", "operacion": "Alquiler", "habitaciones": 3, "precio": 110000, "barrio": "Funes Norte", "features": ["Cochera", "Piscina"], "img": "https://images.unsplash.com/photo-1472224311458-3bc5512397ad?w=500"}, {"id": 10, "tipo": "Departamento", "operacion": "Alquiler", "habitaciones": 2, "precio": 55000, "barrio": "Echesortu", "features": ["Balcón", "Mascotas"], "img": "https://images.unsplash.com/photo-1499955085172-a104c9463ece?w=500"} ] return pd.DataFrame(data) df = get_property_data() # --- FASE 3.3: INTERFAZ - BARRA LATERAL (FILTROS) --- st.sidebar.title("🔍 Filtros de Búsqueda") st.sidebar.markdown("---") op_tipo = st.sidebar.selectbox("Operación", ["Todos", "Alquiler", "Venta"]) prop_tipo = st.sidebar.multiselect("Tipo de Propiedad", ["Casa", "Departamento"], default=["Casa", "Departamento"]) habitaciones = st.sidebar.slider("Mínimo de Habitaciones", 1, 4, 1) precio_max = st.sidebar.number_input("Precio Máximo", value=int(df['precio'].max()), step=5000) features_list = ["Cochera", "Balcón", "Mascotas", "Piscina", "Seguridad"] features_selected = st.sidebar.multiselect("Características deseadas", features_list) # --- FASE 3.2: LÓGICA DE FILTRADO DINÁMICO --- def filter_logic(df_in): res = df_in.copy() if op_tipo != "Todos": res = res[res['operacion'] == op_tipo] res = res[res['tipo'].isin(prop_tipo)] res = res[res['habitaciones'] >= habitaciones] res = res[res['precio'] <= precio_max] if features_selected: res = res[res['features'].apply(lambda x: all(item in x for item in features_selected))] return res df_filtered = filter_logic(df) # --- CUERPO PRINCIPAL --- st.title("🏠 InmoFinder") st.subheader(f"Encontramos {len(df_filtered)} propiedades para vos") # FASE 4: MANEJO DE ERRORES / RESULTADOS VACÍOS if df_filtered.empty: st.warning("⚠️ No hay resultados que coincidan exactamente con tus filtros.") st.info("Sugerencia: Intenta ampliar el rango de precio o reducir las características requeridas.") else: # FASE 3.3: GRILLA DE RESULTADOS (TARJETAS VISUALES) cols = st.columns(2) for index, row in df_filtered.iterrows(): col_idx = index % 2 with cols[col_idx]: st.markdown(f"""

{row['tipo']} en {row['barrio']}

USD {row['precio']:,} | {row['operacion']}

🛏️ {row['habitaciones']} Habitaciones

{' '.join([f'{f}' for f in row['features']])}

""", unsafe_allow_html=True) # --- FOOTER --- st.markdown("---") st.caption("InmoFinder SPA - Desarrollado bajo el framework IABE v3.0")