Post Reply 
Python (Glitch) & 'plotly.express' library
10-14-2023, 03:02 PM
Post: #1
Python (Glitch) & 'plotly.express' library
Hello,


I'm trying to understand Python and more particularly the plotly.express library.

For different reasons, I'm using Glitch to run the program.

The program uses a CSV file called 'sales.csv'.

To simplify, let's say that this file has 3 columns (actually 5):

→ 'product' (A, B or C)
→ 'price'
→ 'qtty' (quantity)

With the following code, a HTML file is generated and, by launching it, I obtain a graphic (a pie):

PHP Code:
import plotly.express as px
import pandas 
as pd

data 
pd.read_csv('https://docs.google.com/ … … … ?output=csv')

figure px.pie(datavalues='qtty'names='product'title='Sold quantity by product')
figure.write_html('Sales-by-product.html')

print(
'sales-by-product succefully generated !'

Now I want to get the sales amount (price * quantity) for each product, but I don't know how to handle the "price * quantity" multiplication with plotly.express (or any other calculation).
I couldn't find an answer on the Internet.

Does anyone know this and can explain it to me?

Thanks for having read me.

Bruno
Sanyo CZ-0124 ⋅ TI-57 ⋅ HP-15C ⋅ Canon X-07 + XP-140 Monitor Card ⋅ HP-41CX ⋅ HP-28S ⋅ HP-50G ⋅ HP-50G
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Python (Glitch) & 'plotly.express' library - FLISZT - 10-14-2023 03:02 PM



User(s) browsing this thread: 1 Guest(s)