DATE:
EXPRIMENT-3
DASHBOARD BY USING NUMPY &PANDAS
AIM: To implement python program by using numpy and pandas for Dashboard.
SOURCE CODE:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import plotly.express as px
# Step 1: Load the dataset from the CSV file
df = pd.read_csv('sales_data.csv')
# Display the data to verify loading
print("Sales Data:")
print(df)
# Step 2: Calculate Total Sales for Each Month
df['Total_Sales'] = df[['Product_A_Sales', 'Product_B_Sales', 'Product_C_Sales']].sum(axis=1)
# Step 3: Matplotlib Visualization - Bar Chart for Total Sales
plt.figure(figsize=(10, 6))
plt.bar(df['Month'], df['Total_Sales'], color='skyblue')
plt.xlabel('Month')
plt.ylabel('Total Sales')
plt.title('Total Monthly Sales')
plt.show()
# Step 4: Plotly Visualization - Line Chart for Individual Products
fig = px.line(df, x='Month', y=['Product_A_Sales', 'Product_B_Sales', 'Product_C_Sales'],
labels={'value': 'Sales', 'variable': 'Product'},
title="Monthly Sales by Product")
fig.show()
DATASET DESCRIPTION:
This dataset represents monthly sales data for a retail business, tracking sales figures for three different
products over six months. It can be used to analyze sales trends and understand overall and product-
specific performance.
Columns in the Dataset:
1. Month: The month of the sales record.
2. Product_A_Sales: The number of units sold for Product A.
3. Product_B_Sales: The number of units sold for Product B.
4. Product_C_Sales: The number of units sold for Product C.
5. Total_Sales: The total sales for all products in a given month (calculated as the sum of sales for
Products A, B, and C).
Month Product_A_Sales Product_B_Sales Product_C_Sales
January 150 200 250
February 180 210 230
March 200 220 240
April 170 190 260
May 160 230 220
June 180 240 210
. Save data set by sales_data.csv
OUTPUT:
Sales Data:
Month Product_A_Sales Product_B_Sales Product_C_Sales Total_Sales
January 150 200 250 600
February 180 210 230 620
March 200 220 240 660
April 170 190 260 620
May 160 230 220 610
June 180 240 210 630
RESULT:
Dashboard using Numpy and Pandas by sales data set is successfully executed.