Lisibonny commited on
Commit
32c554f
1 Parent(s): abbc8e8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -15
app.py CHANGED
@@ -13,6 +13,20 @@ def split_frame(input_df, rows):
13
  df = [input_df.loc[i : i + rows - 1, :] for i in range(0, len(input_df), rows)]
14
  return df
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  def crear_indice():
17
  df=cargar_articulos()
18
  vocab = limpieza_articulos(df)
@@ -124,20 +138,7 @@ def main():
124
  batch_size = 5
125
  pages = split_frame(df_results, batch_size)
126
  pagination = st.container()
127
- with pagination:
128
- N_cards_per_row = 1
129
- for n_row, row in pages.reset_index().iterrows():
130
- i = n_row%N_cards_per_row
131
- if i==0:
132
- st.write("---")
133
- cols = st.columns(N_cards_per_row, gap="large")
134
- # draw the card
135
- with cols[n_row%N_cards_per_row]:
136
- st.caption(f"{row['feed'].strip()} - {row['seccion'].strip()} - {row['fecha'].strip()} ")
137
- st.markdown(f"**{row['titulo'].strip()}**")
138
- st.markdown(f"{row['resumen'].strip()}")
139
- st.markdown(f"{row['link']}")
140
-
141
  bottom_menu = st.columns((2,1,1))
142
  with bottom_menu[1]:
143
  total_pages = (ceil(len(df_results) / batch_size) if ceil(len(df_results) / batch_size) > 0 else 1)
@@ -147,7 +148,7 @@ def main():
147
 
148
  st.markdown(f"Página **{current_page}** de **{total_pages}** ")
149
 
150
- pagination.dataframe(data=pages[current_page - 1], use_container_width=True)
151
 
152
  if __name__ == "__main__":
153
  main()
 
13
  df = [input_df.loc[i : i + rows - 1, :] for i in range(0, len(input_df), rows)]
14
  return df
15
 
16
+ def paginar_frame(df):
17
+ N_cards_per_row = 1
18
+ for n_row, row in df.reset_index().iterrows():
19
+ i = n_row%N_cards_per_row
20
+ if i==0:
21
+ st.write("---")
22
+ cols = st.columns(N_cards_per_row, gap="large")
23
+ # draw the card
24
+ with cols[n_row%N_cards_per_row]:
25
+ st.caption(f"{row['feed'].strip()} - {row['seccion'].strip()} - {row['fecha'].strip()} ")
26
+ st.markdown(f"**{row['titulo'].strip()}**")
27
+ st.markdown(f"{row['resumen'].strip()}")
28
+ st.markdown(f"{row['link']}")
29
+
30
  def crear_indice():
31
  df=cargar_articulos()
32
  vocab = limpieza_articulos(df)
 
138
  batch_size = 5
139
  pages = split_frame(df_results, batch_size)
140
  pagination = st.container()
141
+
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  bottom_menu = st.columns((2,1,1))
143
  with bottom_menu[1]:
144
  total_pages = (ceil(len(df_results) / batch_size) if ceil(len(df_results) / batch_size) > 0 else 1)
 
148
 
149
  st.markdown(f"Página **{current_page}** de **{total_pages}** ")
150
 
151
+ paginar_frame(pages[current_page - 1])
152
 
153
  if __name__ == "__main__":
154
  main()