Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Python Pandasii Assignment1

The document is an assignment for Class XII Informatics Practices at KIIT World School, focusing on various tasks related to creating and manipulating dataframes using Python's Pandas library. It includes questions on creating dataframes from lists, performing operations on series, and displaying specific records from dataframes. The assignment is structured with numbered questions, each specifying the required task and corresponding marks.

Uploaded by

kanishka.gaur
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python Pandasii Assignment1

The document is an assignment for Class XII Informatics Practices at KIIT World School, focusing on various tasks related to creating and manipulating dataframes using Python's Pandas library. It includes questions on creating dataframes from lists, performing operations on series, and displaying specific records from dataframes. The assignment is structured with numbered questions, each specifying the required task and corresponding marks.

Uploaded by

kanishka.gaur
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

KIIT World School

I am a Promise, I am a Possibility

ASSIGNMENT Pandas -II Informatics Practices (2024-25)


Class XII
Date of Giving :- 8-Aug-24 Date of Return:-

S.No. Questions Marks


Write a python code to create a dataframe with appropriate heading from the list given:
1 ['S101','Amy',70], ['S102','Bandhi',69],['S103','Cathy',75],['S105','Madhav ',70] 2
Write a Python Code to create a dataframe with heading ( a and b) from the list given below:
2 [[1,2],[3,4],[5,6],[7,8]] 2
Find the Output of the follwing :
import pandas as pd
data =[{'a':10,'b':20},{'a':6,'b':32,'c':22}]
df1=pd.DataFrame(data,index=['first','second'],columns=['a','b'])
df2=pd.DataFrame(data,index=['first','second'],columns=['a','b1'])
print(df1)
3 print(df2) 2
Consider two series objects staff and salaries that stores the number of people in various office
braches and salaries distributed in these branches , respectively.
Write a statement to create another Series object that stores average salary per branch and then
create a DataFrame object from these Series objects. The libraries Pandas has been imported as
4 pd and the Series objects namely staff and salaries have already been created. 2
Write a program to create a dataFrame from a list containing 2 lists , each containg Target and
5 actual Sales Figure of four zonal offces . Give appropriate row lables. 2
Write a program to create a DataFrame from to store weight , age and names of 3 people. Print
6 the DataFrame and its transponse. 2
A DataFrame Result stores the details of student's marks in different subjects for a class of 50
students. The records are arranged in the descending order of Total marks obtained by a
students. (1) Write a statment to print
the top five scoring students details. (2)
Write a statment to print the five least scoring studetns' details.
(3) Write a statment to print three highest scoring studetnt.
7 (4) Write a statment to print three level lowest scoring studetns. 4
Hitesh wants to display the last four rows of the dataframe df and has writing the following code
:
df.tail()
But last 5 rows are being displayed . Identify the error and rewrite the correct code so that last 4
8 rows get displayed. 2
9 Write a small python code to drop a row from dataframe labeld as o. 2
1. Write the output of the following code:
import numpy as np import pandas as pd
A = np.array([35, 40, 71, 25])
B = np.array([27, 34, 56, 73])
C = [11, 22, 33, 44]
10 DF = pd.DataFrame([A, B, C]) print(DF) 2
KIIT World School
I am a Promise, I am a Possibility
2. Complete the following code to get the Output given below:
import pandas as
L1 = [["Aman", 45], ["Ankit", 56], ["_ ", 67]]
DF = pd. _(L1, =["Name", "Marks"], index=[ ]) print(DF)
Output:
Name Marks
1 Aman 45
2 Ankit 56
11 3 Sunita 67 2

3. Which attribute of dataframe is used for the following:


(i) To display row labels.
(ii) To display column labels.
(iii) To display data type of each column in the DataFrame.
(iv) To display all the values in the DataFrame.
(v) To display number of rows and columns in a tuple.
(vi) To display total number of values in the dataframe.
(vii) To transpose the dataframe.
12 (viii) To returns the value True if DataFrame is empty and False otherwise. 8
Write the code to delete the columns with label ‘Marks’, ‘Class’ and ‘Rollno’ from
13 dataframe “DF”. 2
Raman wants to change the column label “Salary” to “Salaries”. Help him to write the
14 code. 2
15 Write two differences between del statement and drop() function of pandas dataframe. 2
16 Write the code to insert column “Amit” with values (90, 92, 95, 89) at position 2. 2
17 Write the statement to display marks of “Amit” in “Maths”. 2

You might also like