Informatics Practices

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.

Python Pandas

8 Likes

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].

Answered By

5 Likes


Related Questions