0% found this document useful (0 votes)
41 views19 pages

Grade 12 Worksheets - Chapter1

The document consists of a series of questions and programming tasks related to the use of Pandas in Python, covering topics such as creating Series, manipulating data, and understanding properties of Series and DataFrames. It includes exercises for creating, modifying, and displaying Series, as well as questions about the behavior of Pandas functions and methods. The document serves as a worksheet for students learning data handling using Pandas.

Uploaded by

gt
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)
41 views19 pages

Grade 12 Worksheets - Chapter1

The document consists of a series of questions and programming tasks related to the use of Pandas in Python, covering topics such as creating Series, manipulating data, and understanding properties of Series and DataFrames. It includes exercises for creating, modifying, and displaying Series, as well as questions about the behavior of Pandas functions and methods. The document serves as a worksheet for students learning data handling using Pandas.

Uploaded by

gt
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
You are on page 1/ 19

Q.

1-
Given the following Series1

Write the command to create above Series and then double the value in series and store in another series
named Series2
Q.2-
State whether True or False
a. A series object is size mutable.
b. A DataFrame object is value mutable
Q.3-
Consider a given Series , Series1:
200 700
201 700
202 700
203 700
204 700
Write a program in Python Pandas to create the series and display it.
Q.4-
Consider the following Series object,
IP 95
Physics89
Chemistry 92
Math 95
i. Write the Python syntax which will display only IP.
ii. Write the Python syntax to increase marks
of all subjects by 10.
Q.5-
Consider a given series : SQTR
QTR1 50000
QTR2 65890
QTR3 56780
QTR4 89000
QTR5 77900
Write a program in Python Pandas to create and display the series.

Q.6-
What will be the output produced by the following programming statements 1 & 2? import pandas as pd
S1=pd.Series(data=[31,41,51]) print(S1>40) -->Statement1 print(S1[S1>40]) -->Statement2
Q.7-
Given two series S1 and S2
S1 S2
A 39 A 10
B 41 B 10
C 42 D 10
D 44 F 10
Find the output for following python pandas statements?
a. S1[ : 2]*100
b. S1 * S2
c. S2[ : : -1]*10
Q.8-
Given the following Series S1 and S2:
S1 S2
A 10 A 5
B 20 B 4
C 30 C 6
D 40 D 8
Write the command to find the multiplication of series S1 and S2
Q.9-
Consider a given Series , Subject: ENGLISH 75
HINDI 78
MATHS 82
SCIENCE 86
Write a program in Python Pandas to create this series
Q.10-
Consider the following Series object, “company” and its profit in Crores
TCS 350
Reliance 200
L&T 800
Wipro 150
i. Write the command which will display the name of the company having profit>250.
ii. Write the command to name the series as Profit.
Q.11-
Consider two objects a and b.
a is a list whereas b is a Series. Both have values 10,20,25,50.
What will be the output of the following two statements considering that the above objects have been
created already
a. print(a*2) b. print(b*2) Justify your answer.
Q.12-
Given a Pandas series called Sample, the command which will display the last 3 rows is .
a. print(Sample.tail(3))
b. print(Sample.Tail(3))
c. print(Sample.tails(3)
d. print(Sample.Tails(3))
2024-2025
NAME: SUBJECT: IP
CLASS:XII CHAPTER: DATA HANDLING USING PANDAS – 1
DATE: WORK SHEET NO: 2

1.What will be the output of the following code?


import pandas as pd
s = pd.Series(6,index=range(0,5)) print(s)

2.If series s1 is having following data,

What would be the result of the command print(s1[3:6])?


3.What will be the output of the following code?
import pandas as pd import numpy as np
s = pd.Series(np.arange(10,50,10)) print(s)
print (s.ndim) print(s.shape) print(len(s))
4.Write a program to create a Series having 10 random numbers in the range of 10 and 20.
5.Consider the following Series ‘s’- 0 4.0
1 5.0
2 7.0
3 NaN
4 1.0
5 10.0
dtype: float64
(i) Write a Python code to add 1 to all the elements.
(ii) Write a code to replace all NaN with 0.
6.Predict the output of the following code. import pandas as pd
import numpy as np
data = {'one':'a','two':'b','three':'c'} s=pd.Series(data)
print(s) print(s.size)

7.Create a Series object S1 using a python sequence [2,4,6,8] and default indices.

8.Write the output of the following code fragment. import pandas as pd


s2=pd.Series(["i","am", "a","student"]) print(s2)

9.Write the output of the following code fragment. import pandas as pd


s1=pd.Series(200,index=range(2,13,2))
print(s1)
10.Write the output of the following code fragment. import pandas as pd
s1=pd.Series(range(2,11,2), index=[x for x in "abcde"])
print(s1)

11.Write the output of the following code fragment. import pandas as pd


import numpy as np
x=np.arange(10,15)
s3=pd.Series(index=x, data=x*2)
s4=pd.Series(x**2,x)
print(s3) print(s4)

12.Sequences section and contribution store the section name ( 'A','B','C','D','E') and contribution
(8900,8700,7800,6500,nil) for charity. Your school has decided to donate more contribution by each
section, so donation has been doubled.
Write code to create series object that stores the contribution amount as the values and section name as
indexes with data type as float32.

13.Write the output of the following code fragment. import pandas as pd


import numpy as np
val1=np.arange(5.25,50,10.25)
ser1=pd.Series(val1,index=['a','b','a','a','b']) print(ser1)
print(ser1['a'])
print(ser1['b'])

14.Consider a series object s10 that stores the number of students in each section of class 12 as shown
below. First two sections have been given task for selling tickets @ Rs.100/- per ticket as a part of social
experiment. Write code to create the series and display how much section A and B have collected.
A 39
B 31
C 32
D 34
E 35

15.Consider the series s4 as given below


0 2.50
1 17.45
2 20.25
3 87.25
4 33.76
What will be the output after executing the following:
S4[0]=1.75 S4[2:4]= -23.74
print(S4)

16.Consider the following code-


import pandas
s1=pandas.Series([2,3,4,5,6],index=['a','b','c','d','e'])
s1[1:5:2]=345.6
s1[2:4]= -14.65
print(s1)
What will be the output after executing the code.

2024-2025
NAME: SUBJECT: IP
CLASS:XII CHAPTER: DATA HANDLING USING PANDAS – 1
DATE: WORK SHEET NO: 3

Q.1.Consider the Series object s12 that stores the contribution of each section, as shown below:
A 6700
B 8000
C 5400
D 3400
Write code to modify the amount of section 'A' as 8800 and for section 'C' and 'D' as 7700. Print the
changed object.
Q.2.A Series object training data consists of 2000 rows of data. Write a program to print
(i) First 100 rows of data (ii) Last 5 rows of data
Q.3.Consider the following Series s3-
a 1.5
b 3.0
c 4.5
d 6.0
e 7.5
Now create the above series and find the output of the following commands-
i) print(s3+3) ii) print(s3*2)
iii) print(s3>3.0) iv) print(s3[s3>3.0])
Q.4.Consider the Series object s12 that stores the contribution of each section, as shown below:
A 6700
B 8000
C 5400
D 3400
Write code to create the series and display those sections that made the contribution more than
Rs. 5600/-
Q.5.Number of students in class 11 and 12 in three streams( 'Science', 'Commerce' and 'Humanities') are
stored in two series objects c11 and c12. write code to find total number of students in class 11 and 12 ,
stream wise.
Q.6.Consider the series s1 and s2 and s3-
S1 S2 S3
0 10 0 5 a 3
1 20 1 10 b 6
2 30 2 15 c 9
3 40 3 20 d 10
4 50 4 25 e 11
5 30
6 35
Now find the output of the following-
i) print(S1+S2)
ii) print(S1*S3)
iii) print(S1-S2)

Q.7.Consider the Series object s12 that stores the contribution of each section, as shown below: D
6700
A 8000
B 5400
C 3400
i) Write code to create the series and display all its values sorted in descending order.
ii) Write code to display all its indices sorted in ascending order.
Q.8.Given a Series object shown below:
A 6700
B 8000
C 5400
D 3400
dtype : int64
Why is following code producing error while working on Series object s13?
import pandas as pd
s13.index=range(0,5)
print(s13)

Q.9.What will be the output of the following program:


import pandas as pd
first=[7,8,9]
second=pd.Series(first)
s1=pd.Series(data=first*2)
s2=pd.Series(data=second*2)
print("Series1:")
print(s1)
print("Series2:")
print(s2)

Q.10.What is the output of the following program:


import pandas as pd import numpy as np
data=np.array(['Mon','Tue','Wed','Thu','Fri','Sat',' Sun'])
s=pd.Series(data)
print(s[:4])
print(s[-4:])

Q.11.What is the output of the following program:


import pandas as pd import numpy as np
data=np.array(['Mon','Tue','Wed','Thu','Fri','Sat',' Sun'])
s=pd.Series(data, index=[101,102,103,104,105, 106,107])
print(s[[103,105,107]])

Q.12 What will be the output of the following:


import pandas as pd D={'a':10,'b':11,'c':12}
S=pd.Series(D,index=['b','c','d','a']) print(S)

2024-2025
NAME: SUBJECT: IP
CLASS:XII CHAPTER: DATA HANDLING USING PANDAS – 1
DATE: WORK SHEET NO: 4
1. What is the syntax for creating a series
(A) <series name>=pandas.Series(<list name>,...)
(B) <series name>=pandas.Series(<dictionary name>,...)
(C) <series name>=pandas.Series(<array name>,...)
(D) <series name>=pandas.Series(<scalar value>)
(E) All the above

2. Which of the following is used to create an empty series object


(A) pd.Series(empty) (B) pd.Series(np.NaN) (C) pd.Series( ) (D) All of these

3. Which of the following is used to get the number of dimensions of a Series object
(A) index (B) size (C) itemsize (D) ndim

4. Which of the following is used to get the size of datatype of the items in Series object
(A) index (B) size (C) itemsize (D) ndim

5. Which of the following is used to get the number of elements in a Series object
(A) index (B) size(C) itemsize (D) ndim

6. Which of the following is used to get the number of bytes of the Series data
(A) hasnans (B) ndim(C) nbytes (D) dtype

7. Which of the following is used to check whether a Series object has NaN values
(A) nbytes (B) hasnans(C) dtype (D) ndim

8. What is the use of head( ) function with a Series


(A) Display the last five elements of a Series (B) Displays the first five elements of a Series
(C) Removes the first five elements of a Series (D) Removes the last five elements of a Series

9. Identify the correct statement:


(A) The standard marker for missing data in Pandas is NaN
(B) Series act in a way similar to that of an array
(C) Both of the above
(D) None of the above

10. Minimum number of argument we require to pass in pandas series ?


(A) 1.0 (B) 2.1 (C) 3.2 (D) 4.3

11. Series in Pandas is


(A) 1 dimensional array (B) 2 dimensional array(C) 3 dimensional array (D) None of the above
12. Which of the following thing can be data in Pandas?
(A) a python dict (B) an ndarray (C) a scalar value (D) all of the mentioned

13. Point out the correct statement.


(A) If data is a list, if index is passed the values in data corresponding to the labels in the index will be
pulled out
(B) NaN is the standard missing data marker used in pandas
(C) Series acts very similarly to a array
(D) None of the mentioned
14. Which command is used for installing the Pandas?
(A) pip install python–pandas(B) pip install pandas (C) python install python(D) python install pandas

15. Name a data structure where two–dimensional labelled array that is ordered collection of columns
is used to store heterogeneous data types.
(A) Series (B) NumPy Array (C) DataFrame (D) Panel
16. In a DataFrame, what does axis=0 represents?
(A) Columns (B) Rows (C) Rows and Columns both(D) None of these
17. Which attribute of a DataFrame is used to perform the transpose operation on a DataFrame?
(A) T (B) Ndim (C) Empty (D) Shape

18. Which attribute of a DataFrame is used to get number of axis?


(A) size (B) shape (C) values (D) ndim

19. Which method is used to access vertical subset of a DataFrame?


(A) loc( ) (B) column( ) (C) iloc( ) (D) All of these

20. Which function is used to find most often appeared values from a set of numbers?
(A) mean( ) (B) median( ) (C) mode( ) (D) None of these

21. Which function is used to rename the existing column or index?


(A) ren( ) (B) rename( ) (C) changename( ) (D) namechange( )

22. Which among the following options can be used to create a DataFrame in Pandas?
(A) A scalar value (B) An ndarray (C) A python dict (D) All of the above

23. Which of the following can be used to make a DataFrame?


(A) Series (B) DataFrame (C) Structured ndarray (D) All of the above
24. we can analyze the data in pandas with :
(A) Series (B) DataFrame (C) Both of the above (D) None of the above
25. All pandas data structures are __________mutable but not always________mutable.
(A) size, value (B) semantic, size(C) value, size (D) none of the mentioned

26. Point out the correct statement.


(A) Pandas consist of set of labeled array data structures
(B) Pandas consist of an integrated group by engine for aggregating and transforming data sets
(C) Pandas consist of moving window statistics
(D) All of the mentioned
27. Which of the following object you get after reading CSV file?
(A) DataFrame (B) Character Vector (C) Panel (D) All of the mentioned

2024-2025
NAME: SUBJECT: IP
CLASS:XII CHAPTER:PANDAS- LABEL INDEXING-1
DATE: WORK SHEET NO: 5

Consider the given DataFrame and answer the following questions:


Pname disease age charges
P01 alia viral fever 15 500
P02 kavita viral vever 65 600
P03 manya lung infection 45 1500
P04 peehu dengue 20 1200
P05 kartavya bone fracture 56 4500
P06 manas typhoid 35 5000

Q1. Write program to create the DataFrame “patient”.

Q2. WAC to display details of senior citizen patients.

Q3. WAC to display details of patients who have viral fever.

Q4. WAC to display the names of patients who have viral fever.

Q5. WAC to display details of patients who have viral fever and not senior citizens.

Q6. WAC to display the details of patients in the age group of 40 to 60 without using .loc.

Q7. WAC to display the diseases of the patients in the age group of 40 to 60.

Q8. WAC to display the details of patients who have paid charges in the range of 2000 and 5000. (use

between)

Q9. WAC to display the names and disease of patients who have paid charges in the range of 2000 and

5000. (use between)

Q10. WAC to display details of patients with viral, dengue and typhoid.

Q11. WAC to display name and age of patients with viral, dengue and typhoid.

2024-2025
NAME: SUBJECT: IP
CLASS:XII CHAPTER: DataFrames-INDEXING 2
DATE: WORK SHEET NO: 6

Consider the given DataFrame and answer the following


questions:
names clas sec phy chem eng Proj_rem
100 sush 11 A 34 78 50 Avg
101 adarsh 12 A 40 90 55 Good
102 ravi 11 C 56 50 67 Good
103 manu 12 A 67 65 68 Fair
104 sushma 12 B 50 90 69 Avg

Q1. Write program to create the DataFrame “student”.

Q2. WAC to display the details of class 11 students.

Q3. WAC display the project remarks of all students.

Q4. WAC display project remarks of class 11 students.

Q5. WAC to display all subject marks for class 12 students.

Q6. WAC to display the names and class of section “A” and “B” students.

Q7. Display the details of students who have got Good in their Project remarks

Q8. Change the physics marks of Adarsh to 50.

Q9. WAC to Change the name “sushma” to Sushmita”.

Q10. WAC to change the Project remark to “Excellent” for those who have got more than 80 in

chemistry.

2024-2025
NAME: SUBJECT: IP
CLASS:XII CHAPTER: Operations on DataFrame
DATE: WORK SHEET NO: 7

I. Consider the given DataFrame STOCK and answer the following questions:
item manf qty Price
l1 laptop dell 5 45000
m1 mobile Samsung 2 12000
l2 laptop acer 3 30000
ms1 mouse hp 10 1000
Q1. Create the above DataFrame named stock.
Q2. Display the details of all the laptops.
Q3. Display the details of manufacturers with prices.
Q4. Insert a column named ”color” with the following values (black, black, grey, white) without
using series method.
Q5. Display the manufacturers and prices of all phones and laptops.
Q6. Insert the given rows to store the following details
Item manf qty Price color
m2 mobile oppo 15 15000 blue
sp1 speaker Bose 4 20000 red
Q7. Display the details of mobile phones which have price less than 15000.
Q8. Remove the column color permanently.
Q9. Display the items of Samsung company in the stock.
Q10. Make the price of speaker by “bose” company to 21000
Q11. Delete the column price temporarily by all possible methods.
Q12. Insert a column named ”rating’ with the following values (“A+”,”A”,”B”,”B+”,”A”,”A+”) as
the second column in the DataFrame.
Q13. Increase the price of all A+ laptops by 5%.
14. Delete row with index label l2 temporarily.
Q15. Decrease the price of all mobiles by 15%

II. Give the output of the following expressions:


(a) >>>stock.loc[‘ms1’]
(b) >>>stock.item
(c) >>>stock.iloc[[2,3]]
(d) stock[::-1]
(e) stock.iloc[:4:2]
(f) stock.loc[‘mo1’,’qty’]
(g) stock[‘item’]
(h) stock.loc['l1':'l2']
(i) stock[(stock['color']=='red')] . item

NAME: SUBJECT: IP
CLASS:XII CHAPTER: WORKING WITH CSV FILES AND DATFRAMES
DATE: WORK SHEET NO: 8

Q2. Write command to create a DataFrame stud from the above .csv file.
Q3. Write command to create a DataFrame stud1 after removing the column headers from above .csv file.
Q4. Write command to create a DataFrame stud after removing the column headers from the above .csv
file. The column names should not appear as a record of the DataFrame.
Q5. Write command to create a DataFrame stud2 after skipping 3 rows from the csv file.
Q6. Write command to create a DataFrame stud4 from student.csv by selecting only “name” and “per”
columns from it.
Q7. Write code to create a DataFrame stud5 from student.csv. Also change the names of the following
columns (name,class and sec) to (sname,s_class, section) respectively.
Q8. Write code to create a DataFrame stud5 from student.csv. Also change the names of the following
columns (name,class and sec) to (sname,s_class, section) respectively.
Q9. Write output of the following code:-
>>> stud6 = pd.read_csv("d:\\student.csv", skiprows=1, names=new ,usecols=["sname","s_class"])
>>> stud6

NAME: SUBJECT: IP
CLASS:XII CHAPTER: DATFRAMES(Creation and Selection)
DATE: WORK SHEET NO: 9

Q1. Write a program to create the mentioned DataFrame using the index values

as 10,20,30,40 and 50.

Q2. Write code to display the details of soft toys using loc.
Q3. Write code to display the details of Cot and Baby Socks.

Q4. Write code to display the details in question 2 and 3 by using iloc.

Q5. Write code to display all item names.

Q6. Write code to display all item names along with unitprice.

Q7. Write code to display the first 3 records from the DataFrame.

Q8. Write code to display the details of itemcode A21, C80 and A30 using their default indexes.

Q9. Write code to display the last 4 records from the data frame.

Q10. Write code to display the unitprice and discount of items B26 and C80.

Q11. Write code to display 2nd to 5th record (both inclusive)( they are the default index).

Q12. Write code to display the details of baby suit using iloc.

Q13. Display all the odd numbered records without iloc.

Q14. Display all the even numbered records with iloc.

NAME: SUBJECT: IP
CLASS:XII CHAPTER: DATFRAMES(Delete columns)
DATE: WORK SHEET NO: 10
I. Consider the following DataFrame and answer the following questions:

Q1. Write a program to create the mentioned DataFrame using the index values as 10,20,30,40 and 50.
Q2. Write code to insert a column named “vname” to store the following vendor names- Godrej, P&G,
Godrej, Tata, Godrej ( corresponding to every row)
Q3. Write code to insert a column named “qual” to store the quality specifications which are like a+, a, b,
a+, a for every row.
Q4. Write code to insert a column named “area” to store the following values – west, east, east north and
west for each row with the help of assign function.
Q5. Write a command to insert a column named “acode” with the following values
['123','456','123','345','123'] at the 6th column position ( column index=5)
Q6. Write a command to insert a column named “color” with the following values
['red','blue','green','red','orange'] at the 4th column position ( column index =3)

II. Consider the following DataFrame and answer the following questions:

1. Write a program to create the above DataFrame using the index values as 10,20,30,40 and 50.
2. Write code to delete column qual (using del)
3. Can u delete multiple columns using del?
4. Write code to delete column acode (using pop).
5. Write code to delete column vname (using drop).
6. Write code to delete color and area columns from the DataFrame item1 temporarily in following two
ways:
(a) Specifying axis
(b) Without specifying axis
7. Write code to delete color and area columns from the DataFrame item permanently.

NAME: SUBJECT: IP
CLASS:XII CHAPTER: DATFRAMES
(CREATION, SELECTION, ADD, DELETE)
DATE: WORK SHEET NO: 11

1. Write output of following code:


import pandas as pd
data = [['Ram',10],['Shyam',12],['Rima',13]]
df = pd.DataFrame(data, columns=['Name','Age'],
dtype=float)
print( df)

2.Write python code to create a data frame for the following data.

3. Explain DataFrame. Can it be considered as 1D Array or 2D Array?

4.Give the output of the following code:


import pandas as pd
data = [11,12,13,14,15]
df = pd.DataFrame(data)
print(df)
5. Give the output for the following code.
import pandas as pd
data = [{'a': 1, 'b': 2},{'a': 5, 'b': 10, 'c': 20}]
df1 = pd. DataFrame (data, index=['first', 'second'],columns=['a', 'b'])
df2 = pd. DataFrame (data, index=['first', 'second'], columns=['a', 'b1'])
print(df1)
print(df2)

6.Suppose a data frame contains information about student having columns


rollno, name, class and section.
Write the code for the following:
(i) Add one more column as fee

(ii) Write syntax to transpose data frame.

(iii) Write python code to delete column fee of data frame.

(iv) Write the code to append df2 with df1

7.Given a data frame namely Fruits is given below(fruit names are row labels)

Write code statement to

(a) Find all rows with label “Apple”. Extract all columns

(b) List only the columns Count and Price using loc

(c) List only rows with labels ‘Apple’ and ‘Pear’ using loc

(d) Display the price of pear and lime

(e) Find all rows with label “Apple” using iloc. Extract all columns

(f) display data of 1st to 3rd rows

8. Write python statements to create a data frame for the following data and attempt the questions :-

Name Age Designation


YAMINI 35 PRINCIPAL
DINESH 40 SYSTEM MANAGER
SHYAM 50 TEACHER
(a) Add a column dept using series

(b) Add the details of another employee

(c) Add a column salary using assign

(d) Delete column salary using pop()

(e) Insert another employees information at 2nd position

(f) Delete yamini’s record

(g) Delete designation using drop

NAME: SUBJECT: IP
CLASS:XII CHAPTER: DATFRAMES
(INDEXING AND UPDATING DATAFRAMES)
DATE: WORK SHEET NO: 12

Q1. Create the above DataFrame.


Q2. Display the names and age of all silver members.
Q3. Display all details who are paying fees in the range of 1000 to 1500.
Q4. Display last three records.
Q5. Display the name and type of membership for every alternate member starting second one.
Q6. Display the telephone numbers along with the names of all Dwarka and Rajouri garden members.
Q7. Display the fees for member with member ids m3, m2 and m5.
Q8. Change the membership type of the member named “sid” to platinum.
Q9. Change the address and age of the member with id m4 to ‘naraina’ and 26 respectively.
Q10. Change the type of all silver members with age more than 30 to ‘platinum’.
Q11. Increase the fees of everyone by 1000
Q12. Decrease fees of members playing golf by 10%.
Q13. Update the telephone number of Mr. Deepak to 909090.
Q14. Increase the age of the members with ids m2, m4 and m5 by 4.
Q15. Increase fees by 25% for “hari nagar” residents who play cricket.
Q16. Change the type, major and fees to ‘general’, ’swimming’, 1600 for “mehak” staying in dwarka.

NAME: SUBJECT: IP
CLASS:XII CHAPTER: DATFRAMES
(LABEL INDEXING-3)
DATE: WORK SHEET NO: 13

Q1. Write a program to create the DataFrame “Student”.

Q2. Write command to display the names and section of all students.

Q3. Write command to display the details of the students in the reverse order of their indexes.

Q4. Write command to display the first 4 records ( use all possible methods).

Q5. Write command to display all odd number records.

Q6. Write command to display the records with following row labels 102,104,100.
Q.7.Write command to display the phy, chem and eng marks for first two students. (using iloc and loc).

Q8. Write command to display the last 3 records.

Q9. Write command to display the name, section and project remarks for first three records.

Q10. Write command to display the name, section and Project name for the record with third index.

Q11. Write command to display the names of first 4 records using iloc.

Q12. Write command to display the last 3 records in the reverse order of the records.

Q13. Display the physics marks of student with row label 104.

NAME: SUBJECT: IP
CLASS:XII CHAPTER: DATFRAMES
(LABEL INDEXING-4)
DATE: WORK SHEET NO: 14

Consider the given dataframe and answer the following questions:

Q1. Write program to create the dataframe “Patient”.

Q2. Display the age of patient with row label P05.

Q3. Write command to display the complete records of P02 and P04.

Q4. Write command to display the Diseases of first 4 records using all possible methods

Q5. Write command to display the names, age and charges of all patients.

Q6. Write command to display the details of the patients in the reverse order of their indexes.

Q7. Write command to display all even number records.


Q8. Write command to display the Name and charges for the first two students. (using iloc and loc)

Q10. Write command to display the first 5 records ( use all possible methods).

Q11. Write command to display the name and age for first four patients.

Q12. Write command to display the name of the fourth patient. (all methods)

Q13. Write command to display the last 4 records in the reverse order of the records.

Q14. Write command to display the name, disease and charges for the third and fifth patients.

Q15. Write command to display the disease and charges for all patients except first and second.

You might also like