MatteoScript commited on
Commit
d9cfa0e
·
verified ·
1 Parent(s): be4c23b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -4
app.py CHANGED
@@ -355,7 +355,7 @@ with st.sidebar:
355
  comuni_provincia = st.session_state['comuni_totali']
356
  st.title("Filtri")
357
 
358
- st.tipologia_case = st.selectbox("Tipologia", ("Acquisto Immobile", "Asta Immobiliare"), )
359
  elenco = [d['comune'] for d in comuni_provincia]
360
  comune_input = st.multiselect(
361
  "Comuni",
@@ -386,10 +386,18 @@ with st.sidebar:
386
  prezzo_massimo = prezzo_massimo*1000
387
 
388
  # Carica i file
389
- uploaded_files = st.file_uploader("Choose files", type=["xlsx", "xls", "csv"], accept_multiple_files=True)
 
 
390
 
391
  cerca_premuto = st.button("Cerca", use_container_width=True, type='primary')
392
 
 
 
 
 
 
 
393
  def importa_excel(file):
394
  df = None
395
  if file.name.endswith('.csv'):
@@ -424,11 +432,16 @@ def importa_excel(file):
424
  'Mq':'Superficie',
425
  'Link asta': 'Link'
426
  })
427
- df['PrezzoMq'] = 0 #df['Prezzo'] / df['Superficie']
 
 
 
 
428
  df['Vantaggioso'] = False
429
  df['Vantaggio'] = 50
430
  df['Immagine'] = ""
431
  df['PrezzoMedioMq'] = 0
 
432
  return df
433
 
434
  if cerca_premuto:
@@ -439,7 +452,7 @@ if cerca_premuto:
439
  dfs.append(df)
440
  if dfs:
441
  concatenated_df = pd.concat(dfs, ignore_index=True)
442
- scrivi_dataframe([], False, 'Excel', True, concatenated_df)
443
  #st.write(concatenated_df)
444
  st.success("File Excel importati con successo")
445
 
 
355
  comuni_provincia = st.session_state['comuni_totali']
356
  st.title("Filtri")
357
 
358
+ st.tipologia_case = st.selectbox("Tipologia", ("Asta Immobiliare", "Acquisto Immobile"), )
359
  elenco = [d['comune'] for d in comuni_provincia]
360
  comune_input = st.multiselect(
361
  "Comuni",
 
386
  prezzo_massimo = prezzo_massimo*1000
387
 
388
  # Carica i file
389
+ uploaded_files = None
390
+ if st.tipologia_case == "Asta Immobiliare":
391
+ uploaded_files = st.file_uploader("Choose files", type=["xlsx", "xls", "csv"], accept_multiple_files=True)
392
 
393
  cerca_premuto = st.button("Cerca", use_container_width=True, type='primary')
394
 
395
+ def calcola_prezzo_mq(row):
396
+ if pd.isnull(row['Prezzo']) or pd.isnull(row['Superficie']) or row['Superficie'] == 0:
397
+ return 0
398
+ else:
399
+ return row['Prezzo'] // row['Superficie']
400
+
401
  def importa_excel(file):
402
  df = None
403
  if file.name.endswith('.csv'):
 
432
  'Mq':'Superficie',
433
  'Link asta': 'Link'
434
  })
435
+ df['Prezzo'] = df['Prezzo'].fillna(0).astype(int)
436
+ df['Superficie'] = df['Superficie'].fillna(0).astype(int)
437
+ df['Locali'] = df['Locali'].fillna(0).astype(int)
438
+ df['PrezzoMq'] = df.apply(calcola_prezzo_mq, axis=1)
439
+ df['PrezzoMq'] = df['PrezzoMq'].fillna(0).astype(int)
440
  df['Vantaggioso'] = False
441
  df['Vantaggio'] = 50
442
  df['Immagine'] = ""
443
  df['PrezzoMedioMq'] = 0
444
+
445
  return df
446
 
447
  if cerca_premuto:
 
452
  dfs.append(df)
453
  if dfs:
454
  concatenated_df = pd.concat(dfs, ignore_index=True)
455
+ scrivi_dataframe([], True, 'Excel', True, concatenated_df)
456
  #st.write(concatenated_df)
457
  st.success("File Excel importati con successo")
458