DA108 Lab 08 Assignment
DA108 Lab 08 Assignment
You are working as a data analyst for a retail store. The store maintains sales data for its products, and
your task is to process, analyze, and generate reports using Object-Oriented Programming (OOP) and
Pandas.
Dataset:
You have been given a CSV file (sales_data.csv) with the following columns:
Task
● Attributes:
○ df: Stores the sales dataset as a Pandas DataFrame.
● Methods:
○ load_data(file_path): Loads the dataset.
○ clean_data(): Handles missing values and converts data types.
○ get_total_sales(): Returns total sales (sum of TotalPrice).
○ get_unique_products(): Returns a list of unique products.
○ get_sales_by_category(): Returns total sales per product category.
○ get_top_selling_product(): Returns the product with the highest sales.
● New Methods:
○ get_total_sales_by_customer(customer_id): Returns total sales made by a
specific customer.
○ get_frequent_customers(n): Returns the top n customers who made the most
purchases.
○ get_sales_by_city(): Returns total sales per city.