KnowledgeBoat Logo
|

Informatics Practices

Consider the following DataFrame df and answer any four questions from (i)-(v):

rollnonameUT1UT2UT3UT4
1Prerna Singh24242022
2Manish Arora18171922
3Tanish Goel20221824
4Falguni Jain22202420
5Kanika Bhatnagar15201822
6Ramandeep Kaur20152224

Which of the following statement/s will give the exact number of values in each column of the dataframe ?

(I) print(df.count())
(II) print(df.count(0))
(III) print(df.count)
(IV) print((df.count(axis = 'index')))

Choose the correct option :

(a) both (I) and (II)

(b) only (II)

(c) (I), (II) and (III)

(d) (I), (II) and (IV)

Python Pandas

1 Like

Answer

(I), (II) and (IV)

Explanation

In pandas, the statement df.count() and df.count(0) calculate the number of non-null values in each column of the DataFrame df. The statement df.count(axis='index') specifies the axis parameter as 'index', which is equivalent to specifying axis=0. This means it will count non-null values in each column of the DataFrame df.

Answered By

3 Likes


Related Questions