CBSE Class 12 Informatics Practices Question 126 of 167

Python Pandas — I — Question 16

Back to all questions
16
Question

Question 13

Carefully observe the following code :

import pandas as pd
Year1 = {'Q1': 5000, 'Q2': 8000, 'Q3': 12000, 'Q4': 18000} 
Year2 = {'A': 13000, 'B': 14000, 'C': 12000}
totSales = {1: Year1, 2: Year2}
df = pd.DataFrame(totSales)
print(df)

Answer the following :

(i) List the index of the DataFrame df.

(ii) List the column names of DataFrame df.

Answer

(i) The index of the DataFrame df is: ['Q1', 'Q2', 'Q3', 'Q4', 'A', 'B', 'C'].

(ii) The column names of the DataFrame df are: [1, 2].