Advertisements
Advertisements
Question
Find the output of the following Python code:
import pandas as pd
com=pd.Series([45, 12, 15, 200], index = ['mouse', 'printer', 'webcam', 'keyboard'])
print (com[1:3])
Short Answer
Solution
The output of the provided Python code would be:
printer 12
webcam 15
dtype: int64
Explanation:
The statement print (com [1:3)) chooses elements with the index labels "printer" and "webcam." This slicer slices the Series from index position 1 (inclusive) to index position 3 (exclusive). The output shows these chosen items and their matching values.
shaalaa.com
Is there an error in this question or solution?