0% found this document useful (0 votes)
7 views2 pages

Python Assignment

Uploaded by

amancsc2212
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Python Assignment

Uploaded by

amancsc2212
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Q1)

There is a dataframe which is a class's marksheet. It gives marks scored by all students in class in
multiple subjects.

Sample:

Student Maths Science Social .....

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:

| Student | Math | Science | English | History |

|---------|------|---------|---------|---------|

| Akhil | 85 | NaN | 78 | 90 |

| Bhanu | 70 | 88 | NaN | 75 |

| Clara | NaN | 90 | 85 | NaN |

| ... | ... | ... | ... | ... |


Write a function that fills in the missing values with the average grade for that subject (column).

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:

| City | Population | Area (sq km) |

|----------|------------|--------------|

| CityA | 500000 | 300 |

| CityB | 1200000 | 500 |

| CityC | 300000 | 150 |

| ... | ... | ... |

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:

| Employee | Department | Age | Salary |

|----------|------------|-----|--------|

| John | HR | 28 | 50000 |

| Sarah | IT | 35 | 75000 |

| Alex | IT | 40 | 80000 |

| Jane | HR | 32 | 55000 |

| ... | ... | ... | ... |

You might also like