Class 12 IP 065 Data Frame and Series last year Questions 2023-2024 Part 1
Question No 1: What is the output of the following code.
import pandas as pd
dd={"One":1,"Two":2,"Three":3,"Seven":7}
rr=pd.Series(dd)
rr["Four"]=4
print(rr)
Question No 2: Which
of the following command will not show first five rows from the Pandas Series
Name s1
1. s1[0:5]
2. s1.head()
3. s1.head(5)
4. s1.head[0:5]
Question No 3:
Assertion (A): A Series is a one dimensional array and a
DataFrame is a two-dimensional array containing sequence of values of any data
type. (int, float, list, string, etc.)
Reason (R): Both Series and DataFrames have by default numeric indexes starting from zero.
(i) Both (A) and (R) are true and (R) is the correct explanation
for (A).
(ii) Both (A) and (R) are true and (R) is not the correct
explanation for (A).
(iii) (A) is true and (R) is false.
(iv) (A) is false but (R) is true.
Question No 4:
The Python code written below has syntactical
errors. Rewrite the correct code and underline the correction(s) made.
import pandas as pd
stud={"Name":"Ramya","Class":11,"House":"Red"}
s=p.Series(s)
print(s)
Question No 5:
Consider the following Python code:
import pandas as pd
S1=pd.Series(['Rubina', 'Jaya', 'Vaibhav'],
index=[10,16,181)
S2=pd.Series( _____________, index=
[10,16,18])
S3=pd.Series([56,67,86],____________)
xiia={'Name':_________, ‘Subject': S2,
'Marks':53)
df=pd.DataFrame(_____)
print(df)
Question No 6:
Complete the Above Python code to display the following output:
|
Name |
Subject |
Marks |
10 |
Rubina |
IP |
56 |
16 |
Jaya |
HSc |
67 |
18 |
Vaibhav |
IP |
86 |
Question No 7:
Consider the given DataFrame “password”:
|
CodeName |
Category |
Frequency |
0 |
aaaaaa |
alpha |
6.91 |
1 |
dragon |
animal |
18.52 |
2 |
baseball |
sport |
1.29 |
3 |
football |
sport |
11.11 |
4 |
monkey |
animal |
3.72 |
5 |
qwerty |
alpha |
1.85 |
6 |
abcde |
alpha |
3.19 |
Write suitable Python statements for the following:
(i) To add a new row with following values:
CodeName - 'abc123'
Category alphanumeric
Frequency - 12.8
(ii) To delete the row with the row label 2.
(iii) To delete the column having column label as
Frequency.
Question No 8:
Kabir, a data analyst, has stored the voter's name and age in a dictionary. Now, Kabir wants to create a list of dictionaries to store data of multiple voters. He also wants to create a DataFrame from the same list of dictionaries having appropriate row labels as shown below:
|
Voter_Name |
VOter_Age |
Ar1001 |
Arjun |
35 |
Ba3002 |
Bala |
23 |
Go4002 |
Dhruv |
19 |
Dh4007 |
Navya |
18 |
Na6005 |
Govinda |
25 |
Help Kabir in writing Python program to complete the task
Question No 9:
Ms. Ritika Conductyed an online assessment and stored the details in a DataFrame Result as given below:
|
Name |
Score |
Attempt |
Qualify |
a |
Atulya |
12.5 |
1 |
yes |
b |
Disha |
9.0 |
3 |
no |
c |
Kavita |
16.5 |
2 |
yes |
d |
Jhon |
15.0 |
1 |
no |
Answer the following questions:
- Predict the
output of the following Python statement:
print(result.loc[
: , ”Attempt”]>1)
- Write the
python statement to display the last three
records.
- Write Python
Statement to display records of “a” and “d” row labels.
OR (option for third part Only)
Write suitable python Statement to retrieve the data store in the file , registered.csv into a DataFrame , “regis”
0 Comments