Anjeev Singh Academy

Python Pandas Assignment – 1 Important Question Answer

Python Pandas (Series) Important Questions Answer

Exam Special Python Pandas Assignment


Que 41. In how many ways you can access the Series object? Write their name.

Answer: Two common ways to access the element of the Series object.
(a) Indexing and (b) Slicing

Que 42. How many types of indexes are possible with the Series object?

Answer: Two types of indexes are possible with the Series object.
(a) Positional Index and (b) Labelled Index

Que 43. What is Positional Index? Give example.

Answer: The Positional index takes an integer value that corresponds to its position in the series starting from 0.

>>> seriesNum = pd.Series([10,20,30])
>>> seriesNum[2]
30

Que 44. What is the Labelled Index? Give example.

Answer: Labelled index takes any user-defined label as an index.

>>> seriesMnths = pd.Series([2, 3, 4],index =[“Feb”, “Mar”,” pr”])
>>> seriesMnths[“Mar”]
3

Que 45. Solve the following questions on the basis of the given code.

>>> data  = ['NewDelhi', 'WashingtonDC', 'London', 'Paris']
>>> indexes = ['India', 'USA', 'UK', 'France']
>>> seriesCapCntry = pd.Series(data , index= indexex)

(a) Write the statement to get NewDelhi as output using a positional index.
(b) Write the statement to get NewDelhi as output using the labelled index.

Answer: (a) seriesCapCntry[0] #positional index

‘NewDelhi’

(b) seriesCapCntry[‘India’] #labelled index

‘NewDelhi’

Que 46. Can you access more than one element of the series either positional or labels?

Answer: Yes. By using Positional and Labelled Indexing

Que 47. In the given code (Que 45), write the statement to display the capital of the UK and India using:
(a) Positional Index and (b) Labelled Index

Answer: (a) Positional Index

>>> seriesCapCntry[ [3, 0]] #positional index
UK London
India New Delhi

(b) Labelled Index

>>> seriesCapCntry[ [‘India’, ‘UK’]] #labelled index
UK London
India New Delhi

Que 48. Can you access more than one element of the series either positional or labels?

Answer: Yes. By using Positional and Labelled Indexing

Sorry! You cannot copy content of this page. Please contact, in case you want this content.

Scroll to Top