Python Assignment
Python Assignment
There is a dataframe which is a class's marksheet. It gives marks scored by all students in class in
multiple subjects.
Sample:
Akhil 70 85 80 ...
Bhanu
..
...
Write a function, which takes in any dataframe of this type, and give me subject wise topper:
Output Sample:
Subject Topper
Maths Akhil
Science Bhanu
... ...
Q2) You have a dataframe containing the grades of students in multiple subjects, but some grades
are missing. Your task is to fill in the missing grades with the average grade of that subject.
Sample:
|---------|------|---------|---------|---------|
| Akhil | 85 | NaN | 78 | 90 |
| Bhanu | 70 | 88 | NaN | 75 |
Q3) You are provided with a dataframe containing information about different cities, including their
populations and areas. Calculate the population density (population per unit area) for each city and
add it as a new column to the dataframe.
Sample:
|----------|------------|--------------|
Q4)
You are provided with a dataframe that contains data on various employees, including their
department, age, and salary. Write a function to compute the average salary for each department.
Sample:
|----------|------------|-----|--------|
| John | HR | 28 | 50000 |
| Sarah | IT | 35 | 75000 |
| Alex | IT | 40 | 80000 |
| Jane | HR | 32 | 55000 |