How to compare data/scores of multiple products

I have scraped all the scores of products in different areas. Now I would like to make comparison of these scores in different areas with selected products. I was thinking of using bar charts (due to lack of imagination and try to do it as simple as possible first).

However, I can’t understand how I select different rows (where the scores are) from the excel file and display this in a bar chart. Would like to know if someone give me some advice

Hey @gplm_beginner !

In Python, the preferred way to manipulate data is using the Pandas library.

  • there is a function for reading an Excel file into a Pandas dataframe. This article may also help you load the data and install some optional dependencies. So for example df = pd.read_excel("path/to/file.xlsx").
  • When your Excel data is in a DataFrame, you will look on how to filter rows depending on a product. There are guides for this in the documentation, here’s one from the 10 minute quickstart. The query would look like df_selected_by_column = df[df['product'] =="your_product"]
  • Finally if you are looking for the simple bar chart you can try Streamlit’s builtin bar_chart, you may need to filter your columns a bit beforehand, like st.bar_chart(df_selected_by_column[["product", "value"]).

If you want users to give you a bit more specific advice, you could provide us with part of the Excel file and a chart example you would want to display :wink:.


1 Like

@andfanilo thanks for your reply.

My excel table looks like attached screenshot

and i read the excel file:

def load_data():
    data = df
    return data
data = load_data()

I just don’t know how I can display the scores of Product A and Product B in a bar chart. So I can compare who is better.

Hey @gplm_beginner, you’re free to use one of the many graph libraries Streamlit supports (Matplotlib/Seaborn, Altair, Plotly, Bokeh to name a few).

For example here is an interactive one using Plotly Express Grouped bar chart with st.plotly_chart:

import streamlit as st
import pandas as pd
import as px

# continue loading the data with your excel file, I was a bit too lazy to build an Excel file :)
df = pd.DataFrame(
    [["Product A", 5.6, 7.8, 5], ["Product B", 5.8, 7.2, 4.9]],
    columns=["Product", "Comfort", "Sound", "Calls"]

fig =, x="Product", y=["Comfort", "Sound", "Calls"], barmode='group', height=400)
# st.dataframe(df) # if need to display dataframe

Afterwards it becomes more of a reading the graph library documentation (notably because I guess you’d prefer to group by score rather than product?) though rather than a Streamlit question…but feel free to edit the code and see the graph result in Streamlit in realtime to better understand what happens when you edit things!

Good luck !