Practical File- Informatics Practices (Class XII)
#1 Create a pandas series from a dictionary of values and an ndarray.
1|Page
#2. Given a Series, print all the elements that are above the 75th percentile.
2|Page
#3 Create a Data Frame quarterly sales where each row contains the item
category, item name, and expenditure. Group the rows by the category, and
3|Page
#4. Create a data frame based on ecommerce data and generate descriptive
statistics (mean, median, mode, quartile, and variance).
4|Page
#5. Create a data frame for examination result and display row labels, column
labels data types of each column and the dimensions
5|Page
#6. Filter out rows based on different criteria such as duplicate rows.
6|Page
#7. Find the sum of each column, or find the column with the lowest mean.
7|Page
#8. Locate the 3 largest values in a data frame.
8|Page
#9. Subtract the mean of a row from each element of the row in a Data Frame.
9|Page
#10. Replace all negative values in a data frame with a 0.
10 | P a g e
#11. Replace all missing values in a data frame with a 999.
11 | P a g e
#12. Importing and exporting data between pandas and CSV file
12 | P a g e
#19. Importing and exporting data between pandas and MySQL database.
Importing Data from MySQL to Data Frame.
13 | P a g e
Exporting data from Data Frame to MYSQL.
14 | P a g e
#16. Given the school result data, analyse the performance of the students on
different parameters, e.g subject wise or class wise.
15 | P a g e
#17. For the Data frames created above, analyze and plot appropriate charts
with title and legend.
16 | P a g e
#18. Take data of your interest from an open source (e.g. [Link]), aggregate
and summarize it. Then plot it using different plotting functions of the Matplotlib
17 | P a g e
18 | P a g e
#20. Create a student table with the student id, name, and marks as attributes
where the student id is the primary key.
#21. Insert the details of a new student in the above table.
#22. Delete the details of a particular student in the above table.
19 | P a g e
#23. Use the select command to get the details of the students with marks
more than 80.
#24. Create a new table (order ID, customer Name, and order Date) by joining
two tables (order ID, customer ID, and order Date) and (customer ID, customer
20 | P a g e
#25. Create a foreign key in one of the two tables mentioned above
#26. Find the min, max, sum, and average of the marks in a student marks table.
#27. Find the total number of customers from each country in the table
(customer ID, customer Name, country) using group by.
21 | P a g e
#28. Create a new table (name, date of birth) by joining two tables (student id,
name) and (student id, date of birth).
#29. Write a SQL query to order the (student ID, marks) table in descending order
of the marks.
22 | P a g e
Program 13: Create a DataFrame and display basic info
import pandas as pd
data = {
"Name": ["Alice", "Bob", "Charlie"],
"Age": [20, 21, 22],
"Marks": [85, 90, 88]
}
df = [Link](data)
print(df)
Output:
Name Age Marks
0 Alice 20 85
1 Bob 21 90
2 Charlie 22 88
Program 14: Select specific columns of Dataframe
print(df[["Name", "Marks"]])
Output:
Name Marks
0 Alice 85
1 Bob 90
2 Charlie 88
Program 15: Display records of a Dataframe where marks are greater than 85
high_marks = df[df["Marks"] > 85]
print(high_marks)
Output:
Name Age Marks
1 Bob 21 90
2 Charlie 22 88
Program 16: Add a new column to the dataframe
df["Passed"] = df["Marks"] >= 40
print(df)
Output:
23 | P a g e
Name Age Marks Passed
0 Alice 20 85 True
1 Bob 21 90 True
2 Charlie 22 88 True
Program 17: create a Line Plot
import [Link] as plt
names = ["Alice", "Bob", "Charlie"]
marks = [85, 90, 88]
[Link](names, marks, marker='o')
[Link]("Students")
[Link]("Marks")
[Link]("Student Marks")
[Link]()
output:
Program 18: Bar Chart
[Link](names, marks, color='skyblue')
[Link]("Students")
[Link]("Marks")
[Link]("Marks Bar Chart")
[Link]()
Output:
Assume this table STUDENTS:
id name age marks
1 Alice 20 85
2 Bob 21 90
3 Charlie 22 88
Query 30: Select all records
SELECT * FROM students;
Output:
id name age marks
1 Alice 20 85
2 Bob 21 90
3 Charlie 22 88
Query31: Select students with marks above 85
SELECT name, marks
24 | P a g e
FROM students
WHERE marks > 85;
Output:
name marks
Bob 90
Charlie 88
Query 32: Count total number of students
SELECT COUNT(*) AS total_students
FROM students;
Output:
total_students
3
Query 33: Find average marks
SELECT AVG(marks) AS average_marks
FROM students;
Output:
average_marks
87.6667
Query 34: Delete records having marks <90
Delete from students where marks<80;
Select * from students;
Output:
2 Bob 21 90
25 | P a g e