10-14-2023, 03:02 PM
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):
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.
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(data, values='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.