Skip to main content
Chapter 2 of 7
NCERT Solutions

Data Handling using Pandas - I

CBSE · Class 12 · Informatics Practices

NCERT Solutions for Data Handling using Pandas - I — CBSE Class 12 Informatics Practices.

100 questions90 flashcards5 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.

1,000+ Class 12 students started this chapter today

46 Questions Solved · 1 Section

23 worked solutions below. Unlock all 46 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
```python
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
```python
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
```python
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
```python
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
```python
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
```python
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
```python
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
```python
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
```python
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
```python
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
```python
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.

```python
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
```python
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
```python
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:

```python
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:

```python
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:

```python
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:

```python
EngAlph.tail(10)
```

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

7hDisplay the MTseries.Show solution
Display the empty Series directly:

```python
print(MTseries)
```

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

8aDisplay the names of the months 3 through 7 from the Series MonthDays.
8bDisplay the Series MonthDays in reverse order.
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.
10aDisplay the row labels of Sales.
10bDisplay the column labels of Sales.
10cDisplay the data types of each column of Sales.
10dDisplay the dimensions, shape, size and values of Sales.
10eDisplay the last two rows of Sales.
10fDisplay the first two columns of Sales.
10gCreate a dictionary using the following data. Use this dictionary to create a DataFrame Sales2.
10hCheck if Sales2 is empty or it contains data.
11aAppend the DataFrame Sales2 to the DataFrame Sales.
11bChange the DataFrame Sales such that it becomes its transpose.
11cDisplay the sales made by all sales persons in the year 2017.
11dDisplay the sales made by Madhu and Ankit in the year 2017 and 2018.
11eDisplay the sales made by Shruti 2016.
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.
11gDelete the data for the year 2014 from the DataFrame Sales.
11hDelete the data for sales man Kinshuk from the DataFrame Sales.
11iChange the name of the salesperson Ankit to Vivaan and Madhu to Shailesh.
11jUpdate the sale made by Shailesh in 2018 to 100000.
11kWrite the values of DataFrame Sales to a comma separated file SalesFigures.csv on the disk. Do not write the row labels and column labels.
11lRead the data in the file SalesFigures.csv into a DataFrame SalesRetrieved and Display it. Now update the row labels and column labels of SalesRetrieved to be the same as that of Sales.

23 more solved questions in Data Handling using Pandas - I

Every remaining exercise is solved step by step in Super Tutor, plus practice quizzes and flashcards for this chapter. Free to start.

Stuck on a step?

Ask Super Tutor AI to explain any solution on this page in a simpler way — free, 24x7.

Ask a Doubt Free

Frequently Asked Questions

What are the important topics in Data Handling using Pandas - I for CBSE Class 12 Informatics Practices?
Data Handling using Pandas - I covers several key topics that are frequently asked in CBSE Class 12 board exams. Focus on the core concepts listed on this page and practise related questions to build confidence.
How to score full marks in Data Handling using Pandas - I — CBSE Class 12 Informatics Practices?
Understand the core concepts first, then work through the 100 practice questions available for this chapter. Revise formulas and definitions regularly, and use flashcards for quick recall before the exam.
Where can I get free NCERT Solutions for Data Handling using Pandas - I Class 12 Informatics Practices?
This page has free step-by-step NCERT Solutions for every exercise question in Data Handling using Pandas - I (CBSE Class 12 Informatics Practices) — written the way examiners award marks: given, formula, working, answer.

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 — for free.

Quizzes, flashcards, AI doubt-solver and a step-by-step study plan for CBSE Class 12 Informatics Practices.