0% found this document useful (0 votes)
12 views4 pages

Student Marks Analysis with Pandas

The document contains five programming examples using Python and pandas for various data manipulations. Programs include creating series for student marks, constructing a DataFrame for student details, sorting a DataFrame, grouping data to calculate mean marks by class, and generating a bar chart for student marks. Each program is aimed at demonstrating different functionalities of pandas and data visualization with matplotlib.

Uploaded by

balajiswamy42
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)
12 views4 pages

Student Marks Analysis with Pandas

The document contains five programming examples using Python and pandas for various data manipulations. Programs include creating series for student marks, constructing a DataFrame for student details, sorting a DataFrame, grouping data to calculate mean marks by class, and generating a bar chart for student marks. Each program is aimed at demonstrating different functionalities of pandas and data visualization with matplotlib.

Uploaded by

balajiswamy42
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

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]()

You might also like