Pandas & Vis 2
Pandas & Vis 2
a. print(df.max)
b. print(df.max())
c. print(df.max(axis=1))
d. print(df.max, axis=1)
2. The teacher needs to know the marks scored by the student with roll number.Help her to identify the
correct set of statement/s from the given options
a.
print(df1)
b. df1=df[rollno==4]
print(df1)
c . df1=df[df.rollno=4]
print(df1)
d. df1=df[df.rollno==4]
print(df1)
3. Which of the following statement/s will give the exact number of values ineach column of the
dataframe?
i) print(df.count())
ii) print(df.count(0))
iii) print(df.count)
iv)
Choose the correct option:
a. both (i) and (ii)
b. only (ii)
c. (i), (ii) and (iii)
d. (i), (ii) and (iv)
4. Which of the following command will display the column labels of thedataframe?
i) print(df.columns())
ii) print(df.column())
iii) print(df.column)
iv) print(df.columns)
5. Ms. Sharma, the class teacher wants to add a new column
a)
b)
c)
d) Both (b) and (c) are correct
ANS:- 1. b. print(df.max())
2.
print(df1)
d. df1=df[df.rollno==4]
print(df1)
3. a. both (i) and (ii)
4. d.print(df.columns)
5.
Q-3Consider the DataFrame dfmks having some missing values(shown as NaN) as shown below:
A B C D
acct 99 94.0 92 97.0
eco 90 94.0 92 97.0
eng 95 89.0 91 89.0
ip 94 NaN 99 95.0
math 97 100.0 99 NaN
ANS:- 1. c.dfmks.fillna(0)
2. b.dfmks.dropna()
3. a.dfmks.isnull()
4.
5. b.import pandas
v)
a.df.Fruits(7152)=9658
b.df.punjab[7152]=9658
]=9658
ANS:- i) b.df.min(axis=1)
ii) c.skipna=True,numeric_value=True
iii)
iv)
v)
Q-5 Consider the following DataFrame df and answer any four questions
2.The output:
11950 818.0
113.1 1.7
will be produced by:
a.df.show[1:3,0:2]
b.df.at[1:3,0:2]
c.df.loc[1:3,0:2]
d.df.iloc[1:3,0:2]
3.Which among given option produce output
Andhra p 3
gujarata 4
kerala 3
Punjab 4
Tripura 4
uttar p 4
a.df.count(axis=1)
b.df.count(axis=0)
c.df.count(rows)
d.df.count(columns)
ANS:- 1.
2. d.df.iloc[1:3,0:2]
3. b.df.T
4. c.median()
5. df.count(axis=1)
Q-6. Mr.Javed is working in a game software development industry and he was comparing the given chart
on the basis of the rating of the various games available on the play store.
He is trying to write a code to plot the
graph. Help him to fill in the blanks of the
code and get the desired output
import__________________________ #Statement 1
Games=["Subway Surfer","Temple Run","Candy Crush","Bottle Shot","Runner Best"]
Rating=[4.2,4.8,5.0,3.8,4.1] plt.______________(Games,Rating) #Statement 2
plt._______________ #Statement 4
i. matplotlib as plt
. Identify the name of the function that should be used in statement 2 to plot the above graph.
i. line()
ii. bar()
iii. hist()
iv.barh()
iv) Choose the right function/method from the following for the statement 4.
i. display()
ii. print()
iii. bar()
iv. show()
v) In case Mr. Javed wants to change the above plot to the any other shape, which statement, should he
change.
i. Statement 1
ii. Statement 2
iii. Statement 3
iv. Statement 4
Answer: Statement 2
Q-7 Khushi is the event incharge in a school. One of her students gave her a suggestion to use Python
Pandas and Matplotlib for analysing and visualising the data, respectively. She has created a Data frame
Third prizes won by different houses in
various events.
a. print(df[::1])
b. print(df.iloc[::-1])
c. print(df[-1:]+df[:-1])
d. print(df.reverse())
ANS: b. print(df.iloc[::-1])
a. df.last(3)
b. df.bottom(3)
c. df.next(3)
d. df.tail(3)
ANS: d. df.tail(3)
x=df.columns[:1]
print(x)
a. 0
b. Name
c. First
d. Error
ANS:- b. Name
a. print(df.size)
b. print(df.shape)
c. print(df.index)
d. print(df.axes)
ANS:- a. df.size