0% found this document useful (0 votes)
3 views3 pages

Python Assignment2

The document outlines a Python assignment focused on data analysis and preprocessing tasks. It includes steps for exploring a dataset, handling missing values and duplicates, standardizing text, detecting and managing outliers, feature engineering, date processing, encoding, group analysis, scaling, and finalizing a cleaned dataset. Each question provides specific instructions to guide the completion of the assignment.

Uploaded by

eyadood352
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Python Assignment2

The document outlines a Python assignment focused on data analysis and preprocessing tasks. It includes steps for exploring a dataset, handling missing values and duplicates, standardizing text, detecting and managing outliers, feature engineering, date processing, encoding, group analysis, scaling, and finalizing a cleaned dataset. Each question provides specific instructions to guide the completion of the assignment.

Uploaded by

eyadood352
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python Assignment

🔹 Question 1 – Initial Exploration


1. Load the dataset.
2. Show first 10 rows.
3. Show dataset shape.
4. Show data types.
5. Show summary statistics.

🔹 Question 2 – Detect Missing Values


1. Count missing values per column.
2. Calculate percentage of missing values.
3. Identify columns with more than 10% missing.

🔹 Question 3 – Handle Missing Values


1. Fill Age with median.
2. Fill Purchase_Amount with mean.
3. Fill Gender & City with mode.
4. Compare dataset before and after cleaning.

🔹 Question 4 – Handle Duplicates


1. Check number of duplicate rows.
2. Remove duplicates.
3. Verify duplicates removed.
🔹 Question 5 – Standardize Text Columns
1. Convert Gender to lowercase.
2. Convert City to title case.
3. Fix inconsistent Product_Category.
4. Remove extra spaces if any.

🔹 Question 6 – Detect Outliers


1. Use describe() to inspect Purchase_Amount.
2. Detect outliers using IQR method.
3. Count number of outliers.

🔹 Question 7 – Handle Outliers


1. Remove extreme outliers
OR
2. Cap values using IQR upper limit
3. Compare statistics before and after.

🔹 Question 8 – Feature Engineering


1. Create column Final_Amount:
2. Purchase_Amount - (Purchase_Amount * Discount / 100)
3. Create Age_Group column:
o 18–25 → Young
o 26–40 → Adult
o 41+ → Senior

🔹 Question 9 – Date Processing


1. Convert Purchase_Date to datetime.
2. Extract:
o Year
o Month
o Day
3. Find number of purchases per month.

🔹 Question 10 – Encoding
1. Encode Gender (Male=1, Female=0).
2. Apply One-Hot Encoding to Product_Category.

🔹 Question 11 – Group Analysis


1. Average Purchase_Amount by City.
2. Total sales per Product_Category.
3. Average Final_Amount by Age_Group.

🔹 Question 12 – Scaling
1. Apply MinMax Scaling on Purchase_Amount.
2. Apply StandardScaler.
3. Compare difference.

🔹 Question 13 – Final Clean Dataset


1. Ensure no missing values remain.
2. Ensure no duplicates.
3. Save cleaned dataset as:
4. Cleaned_Sales_Data.xlsx

You might also like