Question 1407
What will be the output of the following code import pandas as pd dict1 = {'Assam': 'Dispur', 'Manipur': 'Imphal', 'Meghalaya': 'Shillong'} ser = pd.Series(dict1) print(ser[[0,2]])
Answer
Assam Dispur Meghalaya Shillong dtype: object
Why?
The correct option is Assam Dispur Meghalaya Shillong dtype: object CONCEPT: In Series, we can access m ore than one element using a list of positional integers or a list of index labels as shown In the above question, elements at index 0 and 1 of the series 'ser' are accessed using a list of positional integers. This could also be done using index/key values as shown >>>ser[['Assam','Meghalaya']] Output: Assam Dispur Meghalaya Shillong dtype: object
