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

Python Assign 9

The assignment aims to teach the use of Pandas for merging datasets and performing analysis, specifically on the Titanic dataset. It involves creating two DataFrames, merging them on a common key, and conducting grouping and aggregation operations to summarize insights. The findings indicate that passengers in higher classes had higher fares and better survival rates.
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)
5 views3 pages

Python Assign 9

The assignment aims to teach the use of Pandas for merging datasets and performing analysis, specifically on the Titanic dataset. It involves creating two DataFrames, merging them on a common key, and conducting grouping and aggregation operations to summarize insights. The findings indicate that passengers in higher classes had higher fares and better survival rates.
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

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.

You might also like