Wednesday 3 March 2021

CBSE Class 12 (IP)- Data Handling Using Pandas-Part -1 - Questions and Answers (Informatics Practices) (#class12IP)(#eduvictors)(#PythonPandas)

CBSE Class 12 - Data Handling Using Pandas-Part -1 - Questions and Answers
(Informatics Practices) 

CBSE Class 12 - Data Handling Using Pandas-Part -1 - Questions and Answers (Informatics Practices) (#class12IP)(#eduvictors)(#PythonPandas)


Q1: Name any three python libraries commonly used for scientific and analytical use.


Answer: NumPy, Pandas and Matplotlib


Q2: What does NumPy stand for?

Answer: It stands for ‘Numerical Python’. It is a library used for numerical data analysis and scientific computing.


Q3: What does PANDAS stand for?

Answer: Panel Data (PANelDAta).


Q4: What is use of Pandas tool?

Answer: It is a high-level data manipulation tool used for analysing data. It is very easy to import and export data using Pandas library which has a very rich set of functions.


Q5: List the basic features of Pandas library/tool.

Answer

Basic Features of Pandas are:

1. A high-level data manipulation tool used for analysing data

2. Dataframe (Table like) objects help managing data supporting different data types (float, int, string, datetime, etc) all in one place.

3. It has built in functionality for like grouping, joins of data, rolling windows etc.

4. Good IO capabilities; Easily pull/push data from/to different sources like MySQL database, CSV files etc. directly into a dataframe and vice versa.

5. Support Regression analysis, Time-series analysis etc. 

6. Supports reshaping, slicing, sub-setting and pivoting of datasets.

7. Supports data analysis and visualisation (graphs like line graph, bar chart, scatter plots, histograms etc.) using in built Matplotlib


Q6: What is a data structure?

Answer: A data structure is a collection of data values and the operations that can be applied to that data. It enables efficient storage, retrieval and modification to the data. e.g. arrays, lists, dictionaries are examples of some data structures.


Q7: Name the three important data structures supported by Pandas.

Answer: Series, DataFrame and Panel


Q8: Name the tool used to install Pandas library from command prompt.

Answer: pip tool

e.g. pip install pandas


Q9: What does the following statement do?

import pandas as pd

Answer: It imports pandas library with alias/namespace "pd". 


Q10(NCERT): What is a Series and how is it different from a 1-D array, a list and a dictionary?

Answer:  A Series is a one-dimensional array containing a sequence of values of any data type (int, float, list, string, etc) which by default have numeric data labels starting from zero.


Series vs Python Lists (1-D Array):

The main difference is the index: while the Numpy Array  or Python 1-D Array has pre-defined integer index used to access the values i.e. 0,1,2.... In the Pandas Series has an explicitly defined index associated with the values i.e. we can also assign values of other data types as index.

Both can store heterogenous data. 


Panda Series vs Dictionary

Dictionary stores values as key:value pairs. Panda Series are are like one-dimensional array. When you convert dictionary to Series object, keys are converted to user-defined indexes.


Q11: Who developed Pandas?

Answer: McKinney built the basics of Pandas in 2008, and made the project public in 2009.


Q12(MCQ): Which of the following command is used to install pandas?

(a) install pandas

(b) pip install pandas

(c) pip pandas

(d) None of these 


Answer: (b) pip install pandas


Q13: What are three important features of series?

Answer:  Series is like a one-dimensional array (sequence) like structure with homogeneous data (int, float, list, string, etc). For example, the following series is a collection of integers:

CBSE Class 12 - Data Handling Using Pandas-Part -1 - Questions and Answers (Informatics Practices) (#class12IP)(#eduvictors)(#PythonPandas)

Important features of series are:

✌ Heterogenous data

✌ Size Immutable

✌ Values of Data Mutable


Q14: What are the different ways to construct series?

Answer: Series can be created using constructor.

Syntax: pandas.Series(data,index,dtype,copy)

Series can be constructed by using:

1. Scalar Values (constants)

2. By using NumPy Arrays (ndArrays)

3. From Dictionary


Q15: Write a code to create an empty series.

Answer

import pandas as pd

s1 = pd.Series() 

print(s1)

#print statement issues warning 

CBSE Class 12 - Data Handling Using Pandas-Part -1 - Questions and Answers (Informatics Practices) (#class12IP)(#eduvictors)(#PythonPandas)


Q16: How can you check if series is empty?

Answer: Using attribute "empty"


import pandas as pd

s1 = pd.Series() 

print(s1.empty)


Output:

True



Q17: Write Python snippet to create Series object using scalar values [2,4,5,10].

Answer

import pandas as pd

s1 = pd.Series([2,4,5,10]) 

print(s1)

C:\curr\blog\mar2021\series1.png


Q18(NCERT): Create a series having names of any five famous monuments of India and assign their States as index values.

Answer

import pandas as pd

s1 = pd.Series(['India Gate', 'Taj Mahal', 'Gateway Of India',  'Hawa Mahal'], index=['DL', 'UP', 'MH', 'RJ'])

print(s1)

CBSE Class 12 - Data Handling Using Pandas-Part -1 - Questions and Answers (Informatics Practices) (#class12IP)(#eduvictors)(#PythonPandas)


Q19: Write a Python snippet to create a series from a one-dimensional (1D) NumPy array.

Answer:

import pandas as pd

import numpy as np

array1 = np.array([10,20,23,40])

series1 = pd.Series(array1)

print(series1)


Q20: Create a series from a dictionary having names of any five famous monuments of India and assign their States as index values.

Answer:

import pandas as pd

monuments = { 'DL' : 'India Gate',  'UP' : 'Taj Mahal',  'MH' : 'Gateway Of India', 'RJ' : 'Hawa Mahal'}

s1 = pd.series(monuments)

print(s1)


Q21: Name the error displayed when the following snippet is run. Why does this error occur?

import pandas as pd

series5 = pd.Series([1,2,3,4], index = ["Jan", "Feb", "Mar"])


Answer: It will result in a ValueError

When index labels are passed with the array, then the length of the index and array must be of the same size, else it will result in a ValueError.

Here array[1,2,3,4] contains 4 values whereas there are only 3 indices, hence the mismatch and  ValueError is displayed.


👉See Also:

Database Concepts (Important Terms)
Divisibility Rules
SQL Commands (Summary)
Worksheet on Database Management Systems

Python - A Quick Revision (Q & A)
Python Snippets (Set-1)

Informatics Practices Sample Question Paper with Marking Scheme (2020-21)
Informatics Practices Sample Question Paper (Set-2) 2020-21

Important Abbreviations To Memorise
Networking (Q & A)
Networking - Data Transmission Media (Q & A)

 SQL Commands (Summary)
 HTML Basics (1 Mark Based Q & A)
 Worksheet on Database Management Systems

No comments:

Post a Comment

We love to hear your thoughts about this post!

Note: only a member of this blog may post a comment.