Skip to main content
Chapter 2 of 7
NCERT Solutions

Data Handling using Pandas - I — NCERT Solutions

CBSE · Class 12 · Informatics Practices

NCERT question answers for Data Handling using Pandas - I, CBSE Class 12 Informatics Practices: 44 textbook questions solved step by step. Covers Exercise.

100 questions90 flashcards6 formulas & key relations5 concepts

Interactive on Super Tutor

Studying Data Handling using Pandas - I? Get the full interactive chapter.

Quizzes, flashcards, AI doubt-solver and a step-by-step study plan — built for NCERT solutions and more.

Free trial, no card needed.

44 Questions Solved · 1 Section

The first 22 solutions are open to read. The other 22 are free with a Super Tutor account. Unlock all 44 free in Super Tutor

Exercise

1What is a Series and how is it different from a 1-D array, a list and a dictionary?Show solution

A Series is a one-dimensional array in Pandas that stores a sequence of values of any data type and has index labels for each value.

Differences:

  • 1-D array (NumPy ndarray): stores elements in a one-dimensional form, but uses only integer positions for indexing.
  • List: a general Python collection; it does not provide Pandas-style labeled indexing and built-in data analysis methods.
  • Dictionary: stores key:value pairs, while a Series stores values with an index. A Series can be created from a dictionary, but it is not the same thing.

Not sure why a step works? check your working in Super Tutor

2What is a DataFrame and how is it different from a 2-D array?Show solution

A DataFrame is a two-dimensional labelled data structure like a table. It contains rows and columns, and each column may have a different data type.

Difference from a 2-D array:

  • A 2-D array usually stores homogeneous data and is accessed mainly by numeric positions.
  • A DataFrame can store different data types in different columns and uses row and column labels for easier access and analysis.

Not sure why a step works? check your working in Super Tutor

3How are DataFrames related to Series?Show solution

DataFrames are closely related to Series.

  • A DataFrame can be thought of as a collection of Series.
  • Each column in a DataFrame is a Series.
  • When a DataFrame is created from a dictionary of Series, the resulting rows and columns are formed by combining those Series.

Not sure why a step works? check your working in Super Tutor

4What do you understand by the size of (i) a Series, (ii) a DataFrame?Show solution

The size means the total number of data values.

  • For a Series, size = the number of elements in it.
  • For a DataFrame, size = the total number of values in all rows and columns, i.e. rows × columns.

Not sure why a step works? check your working in Super Tutor

5aEngAlph, having 26 elements with the alphabets as values and default index values.Show solution
import pandas as pd

EngAlph = pd.Series(list('abcdefghijklmnopqrstuvwxyz'))
print(EngAlph)

Not sure why a step works? check your working in Super Tutor

5bVowels, having 5 elements with index labels 'a', 'e', 'i', 'o' and 'u' and all the five values set to zero. Check if it is an empty series.Show solution
import pandas as pd

Vowels = pd.Series([0, 0, 0, 0, 0], index=['a', 'e', 'i', 'o', 'u'])
print(Vowels)
print(Vowels.empty)

Vowels.empty will be False because the Series has 5 values, so it is not empty.

Not sure why a step works? check your working in Super Tutor

5cFriends, from a dictionary having roll numbers of five of your friends as data and their first name as keys.Show solution
import pandas as pd

Friends = pd.Series({'Aman': 12, 'Riya': 15, 'Kunal': 8, 'Meena': 20, 'Tarun': 11})
print(Friends)

The dictionary keys become the index labels of the Series.

Not sure why a step works? check your working in Super Tutor

5dMTseries, an empty Series. Check if it is an empty series.Show solution
import pandas as pd

MTseries = pd.Series()
print(MTseries)
print(MTseries.empty)

MTseries.empty will be True because the Series has no values, so it is an empty Series.

Not sure why a step works? check your working in Super Tutor

5eMonthDays, from a numpy array having the number of days in the 12 months of a year. The labels should be the month numbers from 1 to 12.Show solution
import pandas as pd
import numpy as np

MonthDays = pd.Series(np.array([31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]), index=range(1, 13))
print(MonthDays)

Not sure why a step works? check your working in Super Tutor

6aSet all the values of Vowels to 10 and display the Series.Show solution
Vowels[:] = 10
print(Vowels)

This sets all values in the Series to 10.

Not sure why a step works? check your working in Super Tutor

6bDivide all values of Vowels by 2 and display the Series.Show solution
Vowels = Vowels / 2
print(Vowels)

Since all values of Vowels are 10 after the previous step, dividing by 2 gives 5 in each position.

Not sure why a step works? check your working in Super Tutor

6cCreate another series Vowels1 having 5 elements with index labels 'a', 'e', 'i', 'o' and 'u' having values [2,5,6,3,8] respectively.Show solution
Vowels1 = pd.Series([2, 5, 6, 3, 8], index=['a', 'e', 'i', 'o', 'u'])
print(Vowels1)

Not sure why a step works? check your working in Super Tutor

6dAdd Vowels and Vowels1 and assign the result to Vowels3.Show solution
Vowels3 = Vowels + Vowels1
print(Vowels3)

This adds the two Series after matching their index labels and stores the result in Vowels3.

Not sure why a step works? check your working in Super Tutor

6eSubtract, Multiply and Divide Vowels by Vowels1.Show solution
Vowels - Vowels1
Vowels * Vowels1
Vowels / Vowels1

These are the commands for subtraction, multiplication and division of Vowels by Vowels1.

Not sure why a step works? check your working in Super Tutor

6fAlter the labels of Vowels1 to ['A', 'E', 'I', 'O', 'U'].Show solution
Vowels1.index = ['A', 'E', 'I', 'O', 'U']
print(Vowels1)

This changes the index labels of Vowels1 to the given uppercase labels.

Not sure why a step works? check your working in Super Tutor

7aFind the dimensions, size and values of the Series EngAlph, Vowels, Friends, MTseries, MonthDays.Show solution

Use the index, size, and values attributes for each Series.

EngAlph.ndim, EngAlph.size, EngAlph.values
Vowels.ndim, Vowels.size, Vowels.values
Friends.ndim, Friends.size, Friends.values
MTseries.ndim, MTseries.size, MTseries.values
MonthDays.ndim, MonthDays.size, MonthDays.values

Not sure why a step works? check your working in Super Tutor

7bRename the Series MTseries as SeriesEmpty.Show solution
MTseries.name = 'SeriesEmpty'
print(MTseries)

This assigns the Series name SeriesEmpty.

Not sure why a step works? check your working in Super Tutor

7cName the index of the Series MonthDays as monthno and that of Series Friends as Fname.Show solution
MonthDays.index.name = 'monthno'
Friends.index.name = 'Fname'

This names the index of MonthDays as monthno and that of Friends as Fname.

Not sure why a step works? check your working in Super Tutor

7dDisplay the 3rd and 2nd value of the Series Friends, in that order.Show solution

Use positional indexing. Since the 3rd and 2nd values are at positions 2 and 1:

Friends[[2, 1]]

Not sure why a step works? check your working in Super Tutor

7eDisplay the alphabets 'e' to 'p' from the Series EngAlph.Show solution

To display alphabets from 'e' to 'p', use label slicing:

EngAlph['e':'p']

In label slicing, the end label is included.

Not sure why a step works? check your working in Super Tutor

7fDisplay the first 10 values in the Series EngAlph.Show solution

Use head() to get the first 10 values:

EngAlph.head(10)

Not sure why a step works? check your working in Super Tutor

7gDisplay the last 10 values in the Series EngAlph.Show solution

Use tail() to get the last 10 values:

EngAlph.tail(10)

Not sure why a step works? check your working in Super Tutor

7hDisplay the MTseries.

Free with a Super Tutor account

8aDisplay the names of the months 3 through 7 from the Series MonthDays.

Free with a Super Tutor account

8bDisplay the Series MonthDays in reverse order.

Free with a Super Tutor account

9Create the following DataFrame Sales containing year wise sales figures for five sales persons in INR. Use the years as column labels, and sales person names as row labels.
2014201520162017
Madhu100.5120002000050000
Kusum150.8180005000060000
Kinshuk200.9220007000070000
Ankit300003000010000080000
Shruti400004500012500090000

Free with a Super Tutor account

10aDisplay the row labels of Sales.

Use the DataFrame created in Question 9 above to do the following:

Free with a Super Tutor account

10bDisplay the column labels of Sales.

Use the DataFrame created in Question 9 above to do the following:

Free with a Super Tutor account

10cDisplay the data types of each column of Sales.

Use the DataFrame created in Question 9 above to do the following:

Free with a Super Tutor account

10dDisplay the dimensions, shape, size and values of Sales.

Use the DataFrame created in Question 9 above to do the following:

Free with a Super Tutor account

10eDisplay the last two rows of Sales.

Use the DataFrame created in Question 9 above to do the following:

Free with a Super Tutor account

10fDisplay the first two columns of Sales.

Use the DataFrame created in Question 9 above to do the following:

Free with a Super Tutor account

10gCreate a dictionary using the following data. Use this dictionary to create a DataFrame Sales2.
2018
Madhu160000
Kusum110000
Kinshuk500000
Ankit340000
Shruti900000

Free with a Super Tutor account

10hCheck if Sales2 is empty or it contains data.

Use the DataFrame created in Question 9 above to do the following:

Free with a Super Tutor account

11aAppend the DataFrame Sales2 to the DataFrame Sales.

Free with a Super Tutor account

11bChange the DataFrame Sales such that it becomes its transpose.

Free with a Super Tutor account

11cDisplay the sales made by all sales persons in the year 2017.

Use the DataFrame created in Question 9 above to do the following:

Free with a Super Tutor account

11dDisplay the sales made by Madhu and Ankit in the year 2017 and 2018.

Use the DataFrame created in Question 9 above to do the following:

Free with a Super Tutor account

11eDisplay the sales made by Shruti 2016.

Use the DataFrame created in Question 9 above to do the following:

Free with a Super Tutor account

11fAdd data to Sales for salesman Sumeet where the sales made are [196.2, 37800, 52000, 78438, 38852] in the years [2014, 2015, 2016, 2017, 2018] respectively.

Free with a Super Tutor account

11gDelete the data for the year 2014 from the DataFrame Sales.

Free with a Super Tutor account

11hDelete the data for sales man Kinshuk from the DataFrame Sales.

Free with a Super Tutor account

11iChange the name of the salesperson Ankit to Vivaan and Madhu to Shailesh.

Free with a Super Tutor account

11jUpdate the sale made by Shailesh in 2018 to 100000.

Free with a Super Tutor account

22 more solved questions in Data Handling using Pandas - I

They are free with a Super Tutor account, along with practice quizzes and flashcards for this chapter. Free to start, no card needed.

Frequently Asked Questions

What are the important topics in Data Handling using Pandas - I for CBSE Class 12 Informatics Practices?
Key topics in Data Handling using Pandas - I include Python Libraries and Pandas Basics, Series: Creation, Indexing, Slicing, Attributes and Methods, Series Mathematical Operations and Alignment, DataFrame: Creation and Structure. Study these first, then practise questions on each for the CBSE Class 12 board exam.
Are these NCERT Solutions for Data Handling using Pandas - I free?
The first 22 of the 44 solutions on this page are open to read. The other 22 are free with a Super Tutor account — signing up is free and needs no card.
How should I revise Data Handling using Pandas - I for the CBSE Class 12 board exam?
Learn the core ideas first, then work through the 100 practice questions on Data Handling using Pandas - I. Revise definitions regularly and use flashcards for quick recall before the exam.

Sources & Official References

Content is aligned to the official syllabus. Refer to the board website for the latest curriculum.

For serious students

Get the full Data Handling using Pandas - I chapter — start free.

Quizzes, flashcards, an AI doubt solver and a study plan for CBSE Class 12 Informatics Practices. Free to start, no card needed.