CBSE Class 12 Informatics Practices Question 155 of 167

Python Pandas — I — Question 9

Back to all questions
9
Question

Question 6(iv)

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 command will display the column labels of the DataFrame ?

(a) print(df.columns())

(b) print(df.column())

(c) print(df.column)

(d) print(df.columns)

Answer

print(df.columns)

Explanation

The statement df.columns is used to access the column labels (names) of a DataFrame in pandas.