0% found this document useful (0 votes)
5 views

Assignment-7

The document outlines a lab assignment for UCS420 Cognitive Computing, focusing on data analysis using sales data. It includes tasks for generating randomized sales data, performing data manipulation and analysis using Pandas, and creating visualizations with Matplotlib and Seaborn. Additionally, it contains questions related to NumPy operations and Python programming for swapping elements in lists and sets.

Uploaded by

skaushal1be23
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Assignment-7

The document outlines a lab assignment for UCS420 Cognitive Computing, focusing on data analysis using sales data. It includes tasks for generating randomized sales data, performing data manipulation and analysis using Pandas, and creating visualizations with Matplotlib and Seaborn. Additionally, it contains questions related to NumPy operations and Python programming for swapping elements in lists and sets.

Uploaded by

skaushal1be23
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab Assignment 7

UCS420 Cogni ve Compu ng

Q1. You are a data analyst at an e-commerce company. Your task is to analyze sales data,
clean and process it, perform sta s cal analysis, and generate visual insights to help the
business make informed decisions.

1. Use your roll number as the random seed to generate unique data for each student.
2. Follow the ques ons step by step, as each part builds upon the previous one.
3. Submit the assignment as a Jupyter Notebook (.ipynb) with:
 Well-documented code and clear comments.
 Markdown explana ons for each step.
 Screenshots of the plots and outputs.

Part I: Randomized Sales Data Genera on (NumPy)


1. Ini alize Random Seed
2. Generate Sales Data
 Create a NumPy array of random sales data for 12 months (shape = (12, 4)),
where each column represents a product category:
 Electronics, Clothing, Home & Kitchen, Sports.
 Sales values should be between 1000 and 5000 units per month.
 The range should be randomized using the seed.
3. Convert to DataFrame
 Convert the cleaned NumPy array into a Pandas DataFrame with:
i. Columns: Electronics, Clothing, Home & Kitchen, Sports
ii. Index: Months from Jan to Dec

Part II: Data Manipula on and Analysis (Pandas)


1. Display the first 5 rows and summary sta s cs of the DataFrame.
2. Calculate the total sales per category and total sales per month.
3. Calculate the average sales growth between consecu ve months for each category.
4. Add the following columns to the DataFrame:
 Total Sales: Sum of all categories per month.
 Growth Rate: Percentage change in Total Sales from the previous month.
5. Apply a randomized discount:
 If your roll number is even, apply a 10% discount to the Electronics category.
 If odd, apply a 15% discount to the Clothing category.

Part III: Visualiza ons (Matplotlib and Seaborn)


1. Plot monthly sales trends for each category using line plots.
2. Create the following plots:
 Box plots to show the sales distribu on for each category.

Q.2 For the array: array = np.array([[1, -2, 3],[-4, 5, -6]])


i. Find element-wise absolute value
ii. Find the 25th, 50th, and 75th percen le of fla ened array, for each column, for each
row.
iii. Mean, Median and Standard Devia on of fla ened array, of each column, and
each row

Q.3 For the array: a = np.array([-1.8, -1.6, -0.5, 0.5,1.6, 1.8, 3.0]).

i. Find floor, ceiling and truncated value, rounded values

Q.4 WAP to swap two elements in a list in Python Using a Temporary Variable.
Q.5 Write a Python program to swap two elements in a set by conver ng it to a list first.

You might also like