Uvini commited on
Commit
96e968b
·
1 Parent(s): 4bfe754

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -22,10 +22,10 @@ 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
-
26
  # Write the total number of records
27
  st.markdown(
28
- f'<div style="background-color: #4AA6DD; color: #ffffff; padding: 8px; font-size: 30px; font-family: Verdana; font-weight: bold; text-align: center; border-radius: 2rem"> {len(df)} reviews to analyse!</div>',
29
  unsafe_allow_html=True
30
  )
31
 
@@ -62,7 +62,7 @@ if file is not None:
62
 
63
  # Display the sentiment of each review as cards
64
  st.markdown(
65
- f'<div style="background-color: #4AA6DD; color: #ffffff; padding: 6px; font-size: 20px; font-family: Verdana; font-weight: bold; text-align: center; margin-top: 60px; border-radius: 1rem"> What customers said about us</div>',
66
  unsafe_allow_html=True
67
  )
68
 
@@ -73,15 +73,19 @@ if file is not None:
73
  if filter_sentiment != "All":
74
  df = df[df['sentiment'] == filter_sentiment]
75
 
 
 
 
76
  # Create HTML table with no border and centered text
77
  table_html = (df.style
78
- .set_properties(**{'text-align': 'left','font-size': '15px','font-family': 'Verdana'})
79
  .set_table_styles([{'selector': 'th', 'props': [('border', '0px')]},
80
  {'selector': 'td', 'props': [('border', '0px')]}])
81
  .to_html(index=False, escape=False))
82
 
83
- # Display the table and the selectbox widget beside the title
84
- st.write(table_html, unsafe_allow_html=True)
 
85
 
86
 
87
  def convert_df(df):
 
22
  if file is not None:
23
  # Read the CSV file into a Pandas DataFrame
24
  df = pd.read_csv(file)
25
+ st.header(f"<span style='font-family: Verdana; font-size: 30px; color: #52565E;'>{len(df)} reviews to analyse!</span>", unsafe_allow_html=True)
26
  # Write the total number of records
27
  st.markdown(
28
+ 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>',
29
  unsafe_allow_html=True
30
  )
31
 
 
62
 
63
  # Display the sentiment of each review as cards
64
  st.markdown(
65
+ f'<div style="background-color: #4AA6DD; color: #ffffff; padding: 6px; font-size: 20px; font-family: Verdana; font-weight: bold; text-align: center; margin-top: 60px; border-radius: 1rem"> Reviews in depth </div>',
66
  unsafe_allow_html=True
67
  )
68
 
 
73
  if filter_sentiment != "All":
74
  df = df[df['sentiment'] == filter_sentiment]
75
 
76
+ # Set the max number of rows to display at a time
77
+ max_rows = 10
78
+
79
  # Create HTML table with no border and centered text
80
  table_html = (df.style
81
+ .set_properties(**{'text-align': 'left','font-size': '15px','font-family': 'Verdana','margin-bottom':'60px'})
82
  .set_table_styles([{'selector': 'th', 'props': [('border', '0px')]},
83
  {'selector': 'td', 'props': [('border', '0px')]}])
84
  .to_html(index=False, escape=False))
85
 
86
+ # Wrap the table inside a div with a fixed height and scrollable content
87
+ st.write(f'<div style="height: {max_rows*30}px; overflow-y: scroll;">{table_html}</div>', unsafe_allow_html=True)
88
+
89
 
90
 
91
  def convert_df(df):