How to Create a Dashboard With a Dataframe in Python
To create a dashboard with a dataframe in Python, you can use the matplotlib library.
The following example shows how to create a dashboard with a dataframe in Python using the matplotlib library.
Using matplotlib Library
We can use the matplotlib library to create a dashboard.
Suppose we have the following dataframe:
# Import libraries
import pandas as pd
import matplotlib.pyplot as plt
# Create dataframe
office_stuff = pd.DataFrame({
'Date': ['01-03-2023', '01-03-2023', '01-03-2023', '01-03-2023', '02-03-2023', '02-03-2023'],
'Product_Code': ['A-101', 'A-102', 'A-103', 'B-101', 'B-102', 'B-104'],
'Product_Name': ['Laptop', 'Mobile', 'Printer', 'Keyboard', 'Scanner', 'Mouse'],
'Price': [4500, 550, 250, 50, 350, 50],
'Status': [1, 1, 1, 0, 1, 1]
})
# Create column containing total sales of each product
product_sales = office_stuff.groupby('Product_Name').agg({'Price': 'sum'}).reset_index()
# Plot bar chart
plt.bar(product_sales['Product_Name'], product_sales['Price'])
plt.xlabel('Product Name')
plt.ylabel('Total Sales')
plt.title('Total Sales by Product')
plt.show()
Output:
In this example, we use the matplotlib library to create a bar chart dashboard from the dataframe office_stuff.
The output shows the bar chart created from the dataframe.
Conclusion
We can use the matplotlib library to create a dashboard with a dataframe in Python.