Uvini commited on
Commit
5a2d650
1 Parent(s): 5dd6b40

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -18
app.py CHANGED
@@ -16,24 +16,17 @@ st.set_page_config(page_title="Review Analysis", page_icon=":smiley:")
16
  # Add image and heading
17
  st.image("Header.png", use_column_width=True)
18
 
19
- col1, col2 = st.columns(2)
20
- with col1:
21
- file = st.file_uploader(" ", type=["csv"])
22
- with col2:
23
- if file is not None:
24
- st.write(f"{file.name}")
25
- else:
26
- st.write('Please add your CSV to process!')
27
 
28
  # Define the app's functionality
29
  if file is not None:
30
  # Read the CSV file into a Pandas DataFrame
31
  df = pd.read_csv(file)
32
- st.markdown(f"<h5 style='font-family: Verdana;'>Total reviews: {len(df)-1} </h5>", unsafe_allow_html=True)
33
 
34
  # Write the total number of records
35
  st.markdown(
36
- f'<div style="background-color: #4AA6DD; color: #ffffff; padding: 6px; font-size: 16px; font-family: Verdana; font-weight: bold; text-align: center; border-radius: 1rem;margin-top: 40px"> Distribution of Reviews </div>',
37
  unsafe_allow_html=True
38
  )
39
 
@@ -59,39 +52,39 @@ if file is not None:
59
 
60
  with col1:
61
  st.markdown(
62
- f'<div style="background-color: #4AA6DD; color: #ffffff; padding: 6px; font-size: 16px; font-family: Verdana; font-weight: bold; text-align: center; margin-bottom: 40px; border-radius: 1rem">Positive Reviews</div>',
63
  unsafe_allow_html=True
64
  )
65
- wc_pos = WordCloud(width=800, height=400, background_color="white", colormap="winter").generate(positive_reviews)
66
  st.image(wc_pos.to_array(),use_column_width=True)
67
 
68
  with col2:
69
  st.markdown(
70
- f'<div style="background-color: #4AA6DD; color: #ffffff; padding: 6px; font-size: 16px; font-family: Verdana; font-weight: bold; text-align: center; margin-bottom: 40px;border-radius: 1rem">Negative Reviews</div>',
71
  unsafe_allow_html=True
72
  )
73
- wc_neg = WordCloud(width=800, height=400, background_color="white", colormap="winter").generate(negative_reviews)
74
  st.image(wc_neg.to_array(),use_column_width=True)
75
 
76
  # Display the sentiment of each review as cards
77
  st.markdown(
78
- f'<div style="background-color: #4AA6DD; color: #ffffff; padding: 6px; font-size: 16px; font-family: Verdana; font-weight: bold; text-align: center; margin-top: 60px; border-radius: 1rem"> Reviews in depth </div>',
79
  unsafe_allow_html=True
80
  )
81
 
82
  # Add the selectbox to filter sentiments
83
- filter_sentiment = st.selectbox("", ["All", "POSITIVE", "NEGATIVE"])
84
 
85
  # Filter the dataframe based on the selected sentiment
86
  if filter_sentiment != "All":
87
- df = df[df['sentiment'] == filter_sentiment]
88
 
89
  # Set the max number of rows to display at a time
90
  max_rows = 15
91
 
92
  # Create HTML table with no border and centered text
93
  table_html = (df.style
94
- .set_properties(**{'text-align': 'left','font-size': '12px','font-family': 'Verdana'})
95
  .set_table_styles([{'selector': 'th', 'props': [('border', '0px')]},
96
  {'selector': 'td', 'props': [('border', '0px')]}])
97
  .set_table_attributes('style="position: sticky; top: 0;"')
 
16
  # Add image and heading
17
  st.image("Header.png", use_column_width=True)
18
 
19
+ file = st.file_uploader(" ", type=["csv"])
 
 
 
 
 
 
 
20
 
21
  # Define the app's functionality
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: monospace;font-size: 16px;'>Total reviews: {len(df)-1} </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: 16px; font-family: monospace; font-weight: bold; text-align: center; border-radius: 1rem;margin-top: 40px"> Distribution of Reviews </div>',
30
  unsafe_allow_html=True
31
  )
32
 
 
52
 
53
  with col1:
54
  st.markdown(
55
+ f'<div style="background-color: #4AA6DD; color: #ffffff; padding: 6px; font-size: 16px; font-family: monospace; font-weight: bold; text-align: center; margin-bottom: 40px; border-radius: 1rem">Positive Reviews</div>',
56
  unsafe_allow_html=True
57
  )
58
+ wc_pos = WordCloud(width=800, height=600, background_color="white", colormap="winter").generate(positive_reviews)
59
  st.image(wc_pos.to_array(),use_column_width=True)
60
 
61
  with col2:
62
  st.markdown(
63
+ f'<div style="background-color: #4AA6DD; color: #ffffff; padding: 6px; font-size: 16px; font-family: monospace; font-weight: bold; text-align: center; margin-bottom: 40px;border-radius: 1rem">Negative Reviews</div>',
64
  unsafe_allow_html=True
65
  )
66
+ wc_neg = WordCloud(width=800, height=600, background_color="white", colormap="winter").generate(negative_reviews)
67
  st.image(wc_neg.to_array(),use_column_width=True)
68
 
69
  # Display the sentiment of each review as cards
70
  st.markdown(
71
+ f'<div style="background-color: #4AA6DD; color: #ffffff; padding: 6px; font-size: 16px; font-family: monospace; font-weight: bold; text-align: center; margin-top: 60px; border-radius: 1rem"> Reviews in depth </div>',
72
  unsafe_allow_html=True
73
  )
74
 
75
  # Add the selectbox to filter sentiments
76
+ filter_sentiment = st.selectbox("", ["ALL", "POSITIVE", "NEGATIVE"])
77
 
78
  # Filter the dataframe based on the selected sentiment
79
  if filter_sentiment != "All":
80
+ df = df[df['Sentiment'] == filter_sentiment]
81
 
82
  # Set the max number of rows to display at a time
83
  max_rows = 15
84
 
85
  # Create HTML table with no border and centered text
86
  table_html = (df.style
87
+ .set_properties(**{'text-align': 'left','font-size': '12px','font-family': 'monospace'})
88
  .set_table_styles([{'selector': 'th', 'props': [('border', '0px')]},
89
  {'selector': 'td', 'props': [('border', '0px')]}])
90
  .set_table_attributes('style="position: sticky; top: 0;"')