CLASS 12 DATAFRAME WORKSHEET

Question No 1. Create a DataFrame with the following data and find its .shape, .size, .ndim, .dtypes, .columns, .index, and .values.

data = { 'Product': ['Laptop', 'Tablet', 'Smartphone'], 

'Price': [1200, 300, 800], 

'Quantity': [10, 20, 15]}


Quesrion No 2) Create a DataFrame with at least 5 rows and 4 columns of your choice. Write Python code to:

  1. Display the shape of the DataFrame.
  2. Display the number of dimensions.
  3. Show the data types of each column.
  4. Print the row and column labels.
  5. Display the DataFrame as a NumPy array.
Question No 3) Write a brief explanation of each DataFrame attribute in your own words and provide an example for each using a DataFrame of your choice.

Question No 4) For the DataFrame created change the column labels to ['Item', 'Cost', 'Stock'] and check the .columns attribute again.


Post a Comment

0 Comments