DATA SCIENCE PRACTICAL FILE
Subject: Python Programming (Pandas & Matplotlib) and SQL
Academic Year: 2025–26
Student Name: ___________________________
Roll Number: ___________________________
Class / Semester: _______________________
College Name: ___________________________
University / Board: _____________________
Section A: Pandas Programs
Program 1
Aim: To perform Pandas operations on structured data.
Algorithm:
1. Import pandas library.
2. Load or create dataset.
3. Apply required Pandas function.
4. Display the output.
Program Code:
import pandas as pd
# Creating a Pandas Series from a list
data = [10, 20, 30, 40, 50]
series = [Link](data)
print(series)
Output: The result of the Pandas operation is displayed.
Program 2
Aim: To perform Pandas operations on structured data.
Algorithm:
1. Import pandas library.
2. Load or create dataset.
3. Apply required Pandas function.
4. Display the output.
Program Code:
import pandas as pd
# Creating DataFrame using dictionary
data = {
'Name': ['Amit', 'Neha', 'Rahul'],
'Age': [20, 21, 19],
'Marks': [85, 90, 88]
}
df = [Link](data)
print(df)
Output: The result of the Pandas operation is displayed.
Program 3
Aim: To perform Pandas operations on structured data.
Algorithm:
1. Import pandas library.
2. Load or create dataset.
3. Apply required Pandas function.
4. Display the output.
Program Code:
import pandas as pd
# Reading data from CSV file
df = pd.read_csv('[Link]')
print(df)
Output: The result of the Pandas operation is displayed.
Program 4
Aim: To perform Pandas operations on structured data.
Algorithm:
1. Import pandas library.
2. Load or create dataset.
3. Apply required Pandas function.
4. Display the output.
Program Code:
# Display first and last five records
print([Link]())
print([Link]())
Output: The result of the Pandas operation is displayed.
Program 5
Aim: To perform Pandas operations on structured data.
Algorithm:
1. Import pandas library.
2. Load or create dataset.
3. Apply required Pandas function.
4. Display the output.
Program Code:
# Display data types of columns
print([Link])
Output: The result of the Pandas operation is displayed.
Program 6
Aim: To perform Pandas operations on structured data.
Algorithm:
1. Import pandas library.
2. Load or create dataset.
3. Apply required Pandas function.
4. Display the output.
Program Code:
# Statistical summary of data
print([Link]())
Output: The result of the Pandas operation is displayed.
Program 7
Aim: To perform Pandas operations on structured data.
Algorithm:
1. Import pandas library.
2. Load or create dataset.
3. Apply required Pandas function.
4. Display the output.
Program Code:
# Selecting a single column
print(df['Marks'])
Output: The result of the Pandas operation is displayed.
Program 8
Aim: To perform Pandas operations on structured data.
Algorithm:
1. Import pandas library.
2. Load or create dataset.
3. Apply required Pandas function.
4. Display the output.
Program Code:
# Selecting multiple columns
print(df[['Name', 'Age']])
Output: The result of the Pandas operation is displayed.
Program 9
Aim: To perform Pandas operations on structured data.
Algorithm:
1. Import pandas library.
2. Load or create dataset.
3. Apply required Pandas function.
4. Display the output.
Program Code:
# Adding a new column
df['Passed'] = df['Marks'] >= 40
print(df)
Output: The result of the Pandas operation is displayed.
Program 10
Aim: To perform Pandas operations on structured data.
Algorithm:
1. Import pandas library.
2. Load or create dataset.
3. Apply required Pandas function.
4. Display the output.
Program Code:
# Removing a column
[Link]('Passed', axis=1, inplace=True)
print(df)
Output: The result of the Pandas operation is displayed.
Program 11
Aim: To perform Pandas operations on structured data.
Algorithm:
1. Import pandas library.
2. Load or create dataset.
3. Apply required Pandas function.
4. Display the output.
Program Code:
# Filtering records based on condition
high_marks = df[df['Marks'] > 85]
print(high_marks)
Output: The result of the Pandas operation is displayed.
Program 12
Aim: To perform Pandas operations on structured data.
Algorithm:
1. Import pandas library.
2. Load or create dataset.
3. Apply required Pandas function.
4. Display the output.
Program Code:
# Sorting data
sorted_df = df.sort_values(by='Marks', ascending=False)
print(sorted_df)
Output: The result of the Pandas operation is displayed.
Program 13
Aim: To perform Pandas operations on structured data.
Algorithm:
1. Import pandas library.
2. Load or create dataset.
3. Apply required Pandas function.
4. Display the output.
Program Code:
# Handling missing values
[Link](0, inplace=True)
print(df)
Output: The result of the Pandas operation is displayed.
Program 14
Aim: To perform Pandas operations on structured data.
Algorithm:
1. Import pandas library.
2. Load or create dataset.
3. Apply required Pandas function.
4. Display the output.
Program Code:
# Renaming column names
[Link](columns={'Marks': 'TotalMarks'}, inplace=True)
print(df)
Output: The result of the Pandas operation is displayed.
Program 15
Aim: To perform Pandas operations on structured data.
Algorithm:
1. Import pandas library.
2. Load or create dataset.
3. Apply required Pandas function.
4. Display the output.
Program Code:
# Saving DataFrame to CSV file
df.to_csv('updated_student.csv', index=False)
print('File Saved Successfully')
Output: The result of the Pandas operation is displayed.
Section B: Matplotlib Programs
Program 16
Aim: To visualize data using Matplotlib library.
Algorithm:
1. Import [Link].
2. Define data values.
3. Plot graph.
4. Display the graph.
Program Code:
import [Link] as plt
x = [1, 2, 3, 4]
y = [10, 20, 30, 40]
[Link](x, y)
[Link]('X Axis')
[Link]('Y Axis')
[Link]('Line Graph')
[Link]()
Output: Graphical representation of the data is displayed.
Program 17
Aim: To visualize data using Matplotlib library.
Algorithm:
1. Import [Link].
2. Define data values.
3. Plot graph.
4. Display the graph.
Program Code:
import [Link] as plt
names = ['A', 'B', 'C']
marks = [80, 85, 90]
[Link](names, marks)
[Link]('Students')
[Link]('Marks')
[Link]('Bar Chart')
[Link]()
Output: Graphical representation of the data is displayed.
Program 18
Aim: To visualize data using Matplotlib library.
Algorithm:
1. Import [Link].
2. Define data values.
3. Plot graph.
4. Display the graph.
Program Code:
import [Link] as plt
labels = ['Python', 'Java', 'C++']
sizes = [40, 35, 25]
[Link](sizes, labels=labels, autopct='%1.1f%%')
[Link]('Pie Chart')
[Link]()
Output: Graphical representation of the data is displayed.
Program 19
Aim: To visualize data using Matplotlib library.
Algorithm:
1. Import [Link].
2. Define data values.
3. Plot graph.
4. Display the graph.
Program Code:
import [Link] as plt
x = [5, 10, 15, 20]
y = [10, 25, 30, 40]
[Link](x, y)
[Link]('X Values')
[Link]('Y Values')
[Link]('Scatter Plot')
[Link]()
Output: Graphical representation of the data is displayed.
Section C: SQL Queries
Table Name: STUDENT (RollNo, Name, Age, Marks, City)
Query 1
Purpose: To perform SQL operation on STUDENT table.
SELECT * FROM STUDENT;
Result: Displays the appropriate result as per query.
Query 2
Purpose: To perform SQL operation on STUDENT table.
SELECT Name, Marks FROM STUDENT;
Result: Displays the appropriate result as per query.
Query 3
Purpose: To perform SQL operation on STUDENT table.
SELECT * FROM STUDENT WHERE Marks > 80;
Result: Displays the appropriate result as per query.
Query 4
Purpose: To perform SQL operation on STUDENT table.
SELECT * FROM STUDENT WHERE City = 'Delhi';
Result: Displays the appropriate result as per query.
Query 5
Purpose: To perform SQL operation on STUDENT table.
SELECT * FROM STUDENT ORDER BY Marks DESC;
Result: Displays the appropriate result as per query.
Query 6
Purpose: To perform SQL operation on STUDENT table.
SELECT COUNT(*) FROM STUDENT;
Result: Displays the appropriate result as per query.
Query 7
Purpose: To perform SQL operation on STUDENT table.
SELECT AVG(Marks) FROM STUDENT;
Result: Displays the appropriate result as per query.
Query 8
Purpose: To perform SQL operation on STUDENT table.
SELECT MAX(Marks) FROM STUDENT;
Result: Displays the appropriate result as per query.
Query 9
Purpose: To perform SQL operation on STUDENT table.
SELECT MIN(Marks) FROM STUDENT;
Result: Displays the appropriate result as per query.
Query 10
Purpose: To perform SQL operation on STUDENT table.
SELECT City, COUNT(*) FROM STUDENT GROUP BY City;
Result: Displays the appropriate result as per query.
Query 11
Purpose: To perform SQL operation on STUDENT table.
INSERT INTO STUDENT VALUES (1, 'Riya', 20, 88, 'Mumbai');
Result: Displays the appropriate result as per query.
Query 12
Purpose: To perform SQL operation on STUDENT table.
UPDATE STUDENT SET Marks = 90 WHERE RollNo = 1;
Result: Displays the appropriate result as per query.
Query 13
Purpose: To perform SQL operation on STUDENT table.
DELETE FROM STUDENT WHERE Marks < 40;
Result: Displays the appropriate result as per query.
Query 14
Purpose: To perform SQL operation on STUDENT table.
SELECT DISTINCT City FROM STUDENT;
Result: Displays the appropriate result as per query.
Query 15
Purpose: To perform SQL operation on STUDENT table.
SELECT * FROM STUDENT WHERE Name LIKE 'A%';
Result: Displays the appropriate result as per query.