Uvini commited on
Commit
a266dc3
1 Parent(s): 4091915

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -22,11 +22,11 @@ file = st.file_uploader("", type=["csv"])
22
  if file is not None:
23
  # Read the CSV file into a Pandas DataFrame
24
  df = pd.read_csv(file)
25
- st.markdown(f"<h3 style='color: #52565E; font-family: Verdana; font-size: 30px;'>{len(df)} reviews to analyse!</h3>", unsafe_allow_html=True)
26
 
27
  # Write the total number of records
28
  st.markdown(
29
- f'<div style="background-color: #4AA6DD; color: #ffffff; padding: 6px; font-size: 20px; font-family: Verdana; font-weight: bold; text-align: center; border-radius: 1rem;margin-top: 10px"> Distribution of Reviews </div>',
30
  unsafe_allow_html=True
31
  )
32
 
@@ -75,31 +75,33 @@ if file is not None:
75
  df = df[df['sentiment'] == filter_sentiment]
76
 
77
  # Set the max number of rows to display at a time
78
- max_rows = 10
79
 
80
  # Create HTML table with no border and centered text
81
  table_html = (df.style
82
- .set_properties(**{'text-align': 'left','font-size': '15px','font-family': 'Verdana','margin-bottom':'60px'})
83
  .set_table_styles([{'selector': 'th', 'props': [('border', '0px')]},
84
  {'selector': 'td', 'props': [('border', '0px')]}])
 
85
  .to_html(index=False, escape=False))
86
 
87
  # Wrap the table inside a div with a fixed height and scrollable content
88
  st.write(f'<div style="height: {max_rows*30}px; overflow-y: scroll;">{table_html}</div>', unsafe_allow_html=True)
89
 
90
-
91
-
92
  def convert_df(df):
93
  # IMPORTANT: Cache the conversion to prevent computation on every rerun
94
  return df.to_csv().encode('utf-8')
95
 
96
  csv = convert_df(df)
97
 
 
 
 
98
  st.download_button(
99
  label="Download data as CSV",
100
  data=csv,
101
- file_name='Review Sentiments.csv'
 
102
  )
103
-
104
  else:
105
  st.write("Please upload a CSV file.")
 
22
  if file is not None:
23
  # Read the CSV file into a Pandas DataFrame
24
  df = pd.read_csv(file)
25
+ st.markdown(f"<h5 style='font-family: Verdana;'>{len(df)-1} reviews to analyse!</h5>", unsafe_allow_html=True)
26
 
27
  # Write the total number of records
28
  st.markdown(
29
+ f'<div style="background-color: #4AA6DD; color: #ffffff; padding: 6px; font-size: 20px; font-family: Verdana; font-weight: bold; text-align: center; border-radius: 1rem;margin-top: 40px"> Distribution of Reviews </div>',
30
  unsafe_allow_html=True
31
  )
32
 
 
75
  df = df[df['sentiment'] == filter_sentiment]
76
 
77
  # Set the max number of rows to display at a time
78
+ max_rows = 15
79
 
80
  # Create HTML table with no border and centered text
81
  table_html = (df.style
82
+ .set_properties(**{'text-align': 'left','font-size': '15px','font-family': 'Verdana'})
83
  .set_table_styles([{'selector': 'th', 'props': [('border', '0px')]},
84
  {'selector': 'td', 'props': [('border', '0px')]}])
85
+ .set_table_attributes('style="position: sticky; top: 0;"')
86
  .to_html(index=False, escape=False))
87
 
88
  # Wrap the table inside a div with a fixed height and scrollable content
89
  st.write(f'<div style="height: {max_rows*30}px; overflow-y: scroll;">{table_html}</div>', unsafe_allow_html=True)
90
 
 
 
91
  def convert_df(df):
92
  # IMPORTANT: Cache the conversion to prevent computation on every rerun
93
  return df.to_csv().encode('utf-8')
94
 
95
  csv = convert_df(df)
96
 
97
+ # Add some space between the download button and the table
98
+ st.write("<br>", unsafe_allow_html=True)
99
+
100
  st.download_button(
101
  label="Download data as CSV",
102
  data=csv,
103
+ file_name='Review Sentiments.csv',
104
+ style="margin-top: 40px;"
105
  )
 
106
  else:
107
  st.write("Please upload a CSV file.")