DES PUNE UNIVERSITY
School of Engineering and Technology
Computer Engineering and
Technology
Program: [Link]. Electronics and Communication Engineering (AIML)
Academic Year: 2025-26 Year: Second Year Term: II
PRN: 1022512024 Name: Onkar Shinde
Subject: PDS
Assignment No.: 08 Title: Assignment 09
Date: 02/04/2026
AIM
Use Pandas to merge two datasets based on a common key and perform analysis
(e.g., grouping, aggregation) on the merged dataset.
Objective: To learn how to:
• Merge two datasets using Pandas.
• Perform grouping and aggregation operations.
• Summarize insights from merged data.
PSEUDOCODE
• Import Pandas.
• Load Titanic dataset.
• Create two smaller DataFrames from the main dataset.
• Merge them on a common key (PassengerId).
• Perform grouping and aggregation (e.g., mean fare, total survivors per class).
• Display results.
ALGORITHM
● Load the cleaned Titanic dataset.
● Create df1 with PassengerId, Pclass, Fare. ● Create df2 with
PassengerId, Survived.
● Merge df1 and df2 using [Link]().
● Group by Pclass and aggregate:
● Mean Fare
● Sum of Survived
● Print summary table.
Code
import pandas as pd
# Load dataset df =
pd.read_csv("[Link]") # Create two
smaller DataFrames df1 =
df[['PassengerId', 'Pclass', 'Fare']] df2 =
df[['PassengerId', 'Survived']] # Merge
datasets on common key merged =
[Link](df1, df2, on='PassengerId')
print("Merged dataset:\n", [Link]())
# Group and aggregate summary =
[Link]('Pclass').agg({
'Fare': 'mean',
'Survived': 'sum' }).reset_index()
print("Summary by Passenger Class:\n",
summary)
Screenshots
Interpretation :
Passengers in higher classes (Class 1) paid more and had better chances of survival.
Class 2 passengers were in the middle in terms of fare and survival. Class 3
passengers paid the least and had lower survival rates. This means the ticket class
had an impact on survival chances.
Conclusion:
Using Pandas, we can easily combine datasets with a common column. Grouping and
aggregation help us understand patterns clearly. From the data, it is evident that
passengers in higher classes paid more and were more likely to survive.