Write a Python program with suitable comments using pandas that performs the following tasks after
reading the file.
identify missing values,
remove duplicate records,
replace inconsistent values,
fill missing salary values using an appropriate method, and
rename the column headings.
(d) Explain different techniques used for handling missing data. Discuss situations where each technique is
appropriate. (3 Marks)
8
(e) A dataset contains the ages of 500 customers ranging from 18 to 80 years. Explain different ways to
classify these customers into age groups using discretisation (binning). (4 Marks)
(f) Write Python code to detect outliers using the interquartile range method. Also, explain the strategies for
handling outliers in data with the help of suitable examples. (4 Marks)
Q2:
(a) Two data files contain customer details and purchase details having the same format. These files may
contain overlapped data. Write and explain the Python program to merge the two files. Make and state
assumptions, if any (3 Marks)
(b) Explain hierarchical indexing. Illustrate how hierarchical indexing can be used for reshaping datasets
with suitable examples. (3 Marks)
(c) A supermarket dataset contains the following fields: (3 Marks)
Region
Product Category
Sales
Profit
Write a Python program to perform the following tasks:
group data by Region,
calculate total sales,
calculate average profit.
(d) Why is the need to create groups during data analysis? Explain with the help of an example. Explain the
working of the groupby() function in pandas. Discuss grouping using dictionaries, functions and Series
in Python with suitable examples.
(e) Make a synthetic dataset containing monthly sales of three different products for one year. Write a
Python program using Matplotlib and/or Seaborn to generate a line plot and a scatter plot. Make suitable
assumptions.
(f) Write a Python code to demonstrate the purpose of figures, axes, labels, legends, annotations and subplot
arrangements with suitable examples.
Data wrangling is the process of cleaning, transforming, and organizing raw data into a suitable format for analysis and visualization. Python's pandas library provides efficient functions for handling missing values, duplicates, inconsistent entries, and data transformation. ```python # Import pandas import pandas as pd # Read the CSV file df = pd.read_csv("employee_data.csv") # Display missing values in each column print("Missing Values:") print(df.isnull().sum()) # Remove duplicate records df = df.drop_duplicates() # Replace inconsistent values in Gender column df["Gender"] = df["Gender"].replace({ "M": "Male", "F": "Female", "male": "Male", "female": "Female" }) # Fill missing salary values with median salary df["Salary"] = df["Salary"].fillna(df["Salary"].median()) # Rename column headings df = df.rename(columns={ "EmpID": "Employee_ID", "EmpName": "Employee_Name", "Dept": "Department", "Salary": "Monthly_Salary" }) print(df.head()) ``` Missing data handling techniques are essential because incomplete data may reduce the accuracy of analysis. Deletion methods include listwise deletion, where rows containing missing values are removed. This _________ __________ _____ ____ _______ ________ _______ _______.
____ _____ ____ ___ _________ __________.
_______ _________ _________ _____ _____ __________ ________.
_______ ___ ____ _______ ___ ____ _______ ______ ________ _____.
____ _______ __________ _____ ______ __________ ___ ____ ____ ____ _________.
____ _____ ___ ________ _________ ________ ________ ___ _____ _________.
________ ___ __________ _____ _________ ___ _____.
______ _________ ________ _________ _____ _____.
_________ ________ _____ ____ _____ ____ _________ _______ __________ ______ __________ _______.
________ ________ ________ ________ ________.
___ _____ ________ __________ ________ ___ _____.
_________ ___ ____ ____ _________ _____ __________ ______ ______.
_________ ___ __________ ____ __________ __________ ______ ________.
_____ ______ _________ _______ ____ ____ _______ ___.
________ ________ ________ __________ ________ _________ _______.
________ _____ ___ _____ __________ ______ ________ ________.
_____ _______ _________ _____ _________ ______ ___ _______ _______ ___ __________ ______.
________ ____ __________ ____ _____.
_________ ___ _______ ____ _________ _______ ______ ________ ___ ___ _____ _________.
______ _____ ____ _____ _________ _________ __________ ________ ______ _____.
___ ________ ____ ________ _________ _____ ____ _____ ____.
___ __________ _____ ____ ________ _______ ___.
_______ ____ _______ _________ _______ _______ ________ _______ __________ ________ _____.
_______ _______ _____ _______ __________ _______ __________ ____ ________ _____ ________ ____.
___ __________ ___ _________ _________ ___.
_____ _______ ____ _____ ________ ___.
___ __________ ____ _____ _____ _______ ______ ________ _______ ________.
_____ ____ ___ __________ ________ _________ ___ _____ __________ _________ _______ _____.
__________ __________ __________ _______ _____ ________ ______ _______ ____.
____ _________ _________ ____ ______ ______.
_________ ____ _____ _____ __________ _____ ____ ______ ______ _________ __________.
______ ___ __________ ____ __________ ____.
___ ____ __________ ________ ___ ___ ________ ___.
___ ______ ___ __________ ____ _____ ____ ________.
_________ ___ _______ ________ _______ _____ __________ _____.
_______ ________ ____ ________ ______ _________ _____ ___.
________ _______ ____ ______ _____ ____ __________ ________ ____ _________ ___ _________.
_______ __________ ________ ________ _________.
_______ ___ ___ ______ _____ _____ ________ _________ __________ _____ ___.
_____ _________ ______ ____ _____ ___ __________ __________ ____ _________ _________ ______.
______ _____ ______ __________ _____ ________ _____.
________ ___ _____ ________ _________.
_________ _________ ___ ________ ___ _____.
_______ ____ ______ _______ _________ ________ ___ ______ ___ ____ __________ _______.
__________ ________ _____ ______ ___ _____ ____ _______ _____ ____ _________.
__________ ______ _______ ______ ____ ________ ________ __________ ___ __________.
______ ____ __________ _________ ______ _______.
____ _____ ____ _____ ____ ______ _________ ____ _______.
_______ ________ ____ ______ ___ __________ _____ _____ _________ ______ ______ ________.
______ ____ __________ ______ _____ _________ _____ ______ _____ ____ ___ _________.
_______ ______ _________ __________ _________ ____ ______ _______ _________ ___ __________ ___.
______ __________ _______ _________ ______ ________ ______ _______ ____ ______ ____ ________.
_______ ________ ________ _______ __________.
_____ ____ _____ _____ _____ ___ _______.
______ _______ _________ _____ ________ ________ __________ __________ __________.
______ ____ ___ ____ ________ ____ _________ ______ __________ ______ ________ ________.
__________ _________ _______ ________ ________ ________ _________ _________ ________ _____ _________ ____.
____ _______ ____ _________ __________.
__________ ______ ______ _____ _______ __________ _____ ____ ________ __________ __________.
_______ ______ _____ ____ _______ _________ __________.
____ ______ ______ __________ ___ ______ _____ _____ ___ ____.
____ ________ _________ __________ _______ _____ _____ _____ _______.
_________ _______ _________ _____ _________ ___ ________ ______ ______.
________ __________ ____ _________ _____ _____.
_________ _______ ___ _______ ________.
__________ __________ ___ ________ ________ _______ ____ ______ __________ __________ _____.
_______ ___ ________ _________ _____ _________.
___ ___ __________ _________ ___ ______ ___ ________ ______.
_________ __________ ___ ____ _______ ___ _________ ________.
_____ _____ ____ ___ _______ _______ _______ _________ ______.
__________ _______ ______ ___ ________ _______ ______ ___ _____.
__________ _________ _______ _______ ____ ________.
___ ___ ____ __________ _____ ________ _____ _______.
_____ _________ ___ __________ ______.
________ ___ ______ ____ ___ ______.
______ __________ ___ _________ ______ ________ ___ ___.
_______ _______ _______ _______ __________.
____ ________ __________ _____ ________ __________ _________ ____ ________ _____.
_________ _____ ______ ________ ___ _______ _______ ________.
__________ ________ _______ ___ _________ _______ _____ __________ ____ _____ __________ _______.
_____ _______ ___ ____ ________ _______.
________ ____ ______ ____ _______ ______ _____ ___ _____.
___ _________ ______ ________ _______ __________ ________ _____ _______ _____ __________.
_______ _______ ____ ___ _______.
_______ ______ _____ ___ ______ _________ ______ ____ _____ ________ __________ __________.
Get Full Answer on WhatsApp