PROGRAM – 1
Aim:
Write a program to create a series showing the AI marks of three toppers in Class 11, and
another series showing the marks of the same students in Class 12. Then, find the total
marks of each student in both Class 11 and Class 12.
PROGRAM:
import pandas as pd
# Create series for Class 11 and Class 12 marks
class_11_marks = [Link]([95, 98, 92],
index=["Student1", "Student2", "Student3"],
name="Class 11 Marks")
class_12_marks = [Link]([96, 97, 94],
index=["Student1", "Student2", "Student3"],
name="Class 12 Marks")
# Display Class 11 and Class 12 marks
print("Class 11 Marks:\n", class_11_marks)
print("\nClass 12 Marks:\n", class_12_marks)
# Calculate total marks for each student
total_marks = class_11_marks + class_12_marks
print("\nTotal Marks for each student (Class 11 + Class 12):\n", total_marks)
Output:
PROGRAM - 2
Aim:
Write a program to create a DataFrame to store the details of the
age, height, and weight of students participating in athletic meets.
Program:
import pandas as pd
# Create a
dictionary
with student
data data = {
'Name': ['Alice', 'Bob',
'Charlie', 'David', 'Emma'],
'Age': [16, 17, 16, 18, 17],
'Height (cm)': [160, 175, 168, 180, 162],
'Weight (kg)': [50, 68, 59, 72, 54]
}
# Create a DataFrame
from the dictionary
students_df =
[Link](data)
# Display the DataFrame
print("Details of Students Participating
in Athletic Meets:\n") print(students_df)
Output:
PROGRAM-3
Aim: Create a DataFrame from dictionary and sort it.
Code:
import pandas as pd
data={
'name':[ 'aaa', 'bbb', 'ccc'],
'marks':[89, 90, 91]
}
df=[Link](data)
print('original dataframe:\n', df)
#sort by marks
df_sorted=df.sort_values(by='marks', ascending=False)
print('\n sorted dataframe:\n', df_sorted)
PROGRAM-4
Aim: Group data by a column and calculate mean.
Code:
import pandas as pd
data={
'name':['aaa' , 'bbb', 'ccc'],
'class':['xi', 'xii', 'xii'],
'marks':[56,59,78]
}
df=[Link](data)
grouped=[Link]('class')['marks'].mean()
print('average marks by class:\n', grouped)
PROGRAM-5
Aim: create a bar chart for student marks.
Code:
import [Link] as plt
students=['aaaa', 'bbbb', 'cccc']
marks=[89, 78, 67]
[Link] (students, marks,color='blue')
[Link]('students')
[Link]('marks')
[Link]('student marks')
[Link]()