Advertisements
Chapters
▶ 2: Data Handling using Pandas - I
3: Data Handling using Pandas - II
4: Plotting Data using Matplotlib
5: Internet and Web
6: Societal Impacts
Chapter 7: Project Based Learning
![NCERT solutions for Informatics Practices [English] Class 12 chapter 2 - Data Handling using Pandas - I NCERT solutions for Informatics Practices [English] Class 12 chapter 2 - Data Handling using Pandas - I - Shaalaa.com](/images/informatics-practices-english-class-12_6:55813b5fe8c1458f80d0fbe8dfc569b6.jpg)
Advertisements
Solutions for Chapter 2: Data Handling using Pandas - I
Below listed, you can find solutions for Chapter 2 of CBSE NCERT for Informatics Practices [English] Class 12.
NCERT solutions for Informatics Practices [English] Class 12 2 Data Handling using Pandas - I Intext Questions [Pages 30 - 57]
Activity 2.1
Create a series having names of any five famous monuments of India and assign their States as index values.
Think and Reflect
While importing Pandas, is it mandatory to always use pd as an alias name? What would happen if we give any other name?
Activity 2.2
Write the statement to get NewDelhi as output using positional index.
Activity 2.3
Consider the following code:
>>>import pandas as pd >>>import numpy as np >>>s2=pd.
Series([12,np.nan,10]) >>>print(s2)
Find the output of the above code and write a Python statement to count and display only non-null values in the above series.
Activity 2.4
Draw two tables for subtraction similar to tables showing the changes in the series elements and corresponding output without replacing the missing values, and after replacing the missing values with 1000.
| index | value from seriesA |
value from seriesB |
seriesA + seriesB |
| a | 1 | −10 | −9.0 |
| b | 2 | NaN | |
| c | 3 | −50 | −47.0 |
| d | 4 | NaN | |
| e | 5 | 100 | 105.00 |
| y | 20 | NaN | |
| z | 10 | NaN |
| index | value from seriesA |
value from seriesB |
seriesA + seriesB |
| a | 1 | −10 | −9.0 |
| b | 2 | 0 | 2.0 |
| c | 3 | −50 | −47.0 |
| d | 4 | 000 | 4.0 |
| e | 5 | 100 | 105.00 |
| y | 0 | 20 | 20.0 |
| z | 0 | 10 | 10.0 |
Activity 2.5
Draw two tables for multiplication similar to the tables showing the changes in the series elements and corresponding output without replacing the missing values, and after replacing the missing values with 0.
| index | value from seriesA |
value from seriesB |
seriesA + seriesB |
| a | 1 | −10 | −9.0 |
| b | 2 | NaN | |
| c | 3 | −50 | −47.0 |
| d | 4 | NaN | |
| e | 5 | 100 | 105.00 |
| y | 20 | NaN | |
| z | 10 | NaN |
| index | value from seriesA |
value from seriesB |
seriesA + seriesB |
| a | 1 | −10 | −9.0 |
| b | 2 | 0 | 2.0 |
| c | 3 | −50 | −47.0 |
| d | 4 | 000 | 4.0 |
| e | 5 | 100 | 105.00 |
| y | 0 | 20 | 20.0 |
| z | 0 | 10 | 10.0 |
Activity 2.6
Draw two tables for division similar to tables showing the changes in the series elements and corresponding output without replacing the missing values, and after replacing the missing values with 0.
| index | value from seriesA |
value from seriesB |
seriesA + seriesB |
| a | 1 | −10 | −9.0 |
| b | 2 | NaN | |
| c | 3 | −50 | −47.0 |
| d | 4 | NaN | |
| e | 5 | 100 | 105.00 |
| y | 20 | NaN | |
| z | 10 | NaN |
| index | value from seriesA |
value from seriesB |
seriesA + seriesB |
| a | 1 | −10 | −9.0 |
| b | 2 | 0 | 2.0 |
| c | 3 | −50 | −47.0 |
| d | 4 | 000 | 4.0 |
| e | 5 | 100 | 105.00 |
| y | 0 | 20 | 20.0 |
| z | 0 | 10 | 10.0 |
Think and Reflect
>>> import pandas as pd
>>> dFrameEmt = pd.DataFrame()
>>> dFrameEmt
Empty DataFrame
Columns: []
Index: []
What would happen if we pass 3 columns or 5 columns instead of 4 in the above code? What is the reason?
Activity 2.7
Use the type function to check the datatypes of ResultSheet and ResultDF. Are they the same?
Think and Reflect
Can you write a program to count the number of rows and columns in a DataFram?
Think and Reflect
What if in the rename function we pass a value for a row label that does not exist?
Think and Reflect
What would happen if the label or row index passed is not present in the DataFrame?
Activity 2.8
Using the DataFrame ResultDF, write the statement to access Marks of Arnab in Maths.
Create a DataFrame having 5 rows and write the statement to get the first 4 rows of it.
Think and Reflect
How can you check whether a given DataFrame has any missing value or not?
Think and Reflect
What are the other parameters that can be used with read_csv() function? You may explore from https:// pandas.pydata.org.
Besides comma, what are the other allowed characters that can be used as a separator while creating a CSV file frmo a DataFrame?
NCERT solutions for Informatics Practices [English] Class 12 2 Data Handling using Pandas - I Exercise [Pages 60 - 62]
What is a series?
How Series is Different from 1-D Array, List, and Dictionary
What is a DataFrame?
How is the difference between a DataFrame and 2-D array.
How are DataFrames related to Series?
What do you understand by the size of a Serie?
What do you understand by the size of a DataFrame?
Create the following series and do the specified operation:
EngAlph, having 26 elements with the alphabets as values and default index values.
Create the following series and do the specified operation:
Vowels, 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.
Create the following series and do the specified operation:
Friends, from a dictionary having roll numbers of five of your friends as data and their first name as keys.
Create the following series and do the specified operation:
MTseries, an empty series. Check if it is an empty series.
Create the following series and do the specified operation:
MonthDays, 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.
Using the Series created in Question 5, write commands for the following:
- Set all the values of Vowels to 10 and display the Series
- Divide all values of Vowels by 2 and display the Series.
- Create another series Vowels1 having 5 elements with index labels ‘a’, ‘e’, ‘i’, ‘o’ and ‘u’ having values [2,5,6,3,8] respectively.
- Add Vowels and Vowels1 and assign the result to Vowels3
- Subtract, Multiply and Divide Vowels by Vowels1.
- Alter the labels of Vowels1 to [‘A’, ‘E’, ‘I’, ‘O’, ‘U’].
Using the series created in Question 5, write commands for the following:
- Find the dimensions, size and values of the Series EngAlph, Vowels, Friends, MTseries, MonthDays.
- Rename the Series MTseries as SeriesEmpty.
- Name the index of the Series MonthDays as monthno and that of Series Friends as Fname.
- Display the 3rd and 2nd value of the Series Friends, in that order.
- Display the alphabets ‘e’ to ‘p’ from the Series EngAlph.
- Display the first 10 values in the Series EngAlph.
- Display the last 10 values in the Series EngAlph.
- Display the MTseries.
Using the series created in Question 5, write commands for the following:
- Display the names of the months 3 through 7 from the Series MonthDays.
- Display the Series MonthDays in reverse order.
Create 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.
| 2014 | 2015 | 2016 | 2017 | |
| Madhu | 100.5 | 12000 | 20000 | 50000 |
| Kusum | 150.8 | 18000 | 50000 | 60000 |
| Kinshuk | 200.9 | 22000 | 70000 | 70000 |
| Ankit | 30000 | 30000 | 100000 | 80000 |
| Shruti | 40000 | 45000 | 125000 | 90000 |
Use the DataFrame created in Question 9 above to do the following:
- Display the row labels of Sales.
- Display the column labels of Sales.
- Display the data types of each column of Sales.
- Display the dimensions, shape, size and values of Sales.
- Display the last two rows of Sales.
- Display the first two columns of Sales.
- Create a dictionary using the following data. Use this dictionary to create a DataFrame Sales2.
2018 Madhu 160000 Kusum 110000 Kinshuk 500000 Ankit 340000 Shruti 900000 - Check if Sales2 is empty or it contains data.
Use the DataFrame created in Question 9 above to do the following:
- Append the DataFrame Sales2 to the DataFrame Sales.
- Change the DataFrame Sales such that it becomes its transpose.
- Display the sales made by all sales persons in the year 2017.
- Display the sales made by Madhu and Ankit in the year 2017 and 2018.
- Display the sales made by Shruti 2016.
- Add 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.
- Delete the data for the year 2014 from the DataFrame Sales.
- Delete the data for sales man Kinshuk from the DataFrame Sales.
- Change the name of the salesperson Ankit to Vivaan and Madhu to Shailesh.
- Update the sale made by Shailesh in 2018 to 100000.
- Write the values of DataFrame Sales to a comma separated file SalesFigures.csv on the disk. Do not write the row labels and column labels.
- Read 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.
Solutions for 2: Data Handling using Pandas - I
![NCERT solutions for Informatics Practices [English] Class 12 chapter 2 - Data Handling using Pandas - I NCERT solutions for Informatics Practices [English] Class 12 chapter 2 - Data Handling using Pandas - I - Shaalaa.com](/images/informatics-practices-english-class-12_6:55813b5fe8c1458f80d0fbe8dfc569b6.jpg)
NCERT solutions for Informatics Practices [English] Class 12 chapter 2 - Data Handling using Pandas - I
Shaalaa.com has the CBSE Mathematics Informatics Practices [English] Class 12 CBSE solutions in a manner that help students grasp basic concepts better and faster. The detailed, step-by-step solutions will help you understand the concepts better and clarify any confusion. NCERT solutions for Mathematics Informatics Practices [English] Class 12 CBSE 2 (Data Handling using Pandas - I) include all questions with answers and detailed explanations. This will clear students' doubts about questions and improve their application skills while preparing for board exams.
Further, we at Shaalaa.com provide such solutions so students can prepare for written exams. NCERT textbook solutions can be a core help for self-study and provide excellent self-help guidance for students.
Concepts covered in Informatics Practices [English] Class 12 chapter 2 Data Handling using Pandas - I are .
Using NCERT Informatics Practices [English] Class 12 solutions Data Handling using Pandas - I exercise by students is an easy way to prepare for the exams, as they involve solutions arranged chapter-wise and also page-wise. The questions involved in NCERT Solutions are essential questions that can be asked in the final exam. Maximum CBSE Informatics Practices [English] Class 12 students prefer NCERT Textbook Solutions to score more in exams.
Get the free view of Chapter 2, Data Handling using Pandas - I Informatics Practices [English] Class 12 additional questions for Mathematics Informatics Practices [English] Class 12 CBSE, and you can use Shaalaa.com to keep it handy for your exam preparation.
