CBSE Class 12 Informatics Practices Question 11 of 18

Practice Paper — Question 8

Back to all questions
8
Question

Question 24

Give the output:

import pandas as pd
name = ['Rahul','Aman','Karan']
p=pd.Series (name, index= [0,1,2] )
p1 = p.reindex ([1,2,3])
print(p)
print(p1)
Answer
Output
0    Rahul
1     Aman
2    Karan
dtype: object
1     Aman
2    Karan
3      NaN
dtype: object
Explanation

The provided Python code utilizes Pandas to create a Series p using the list name with indices [0, 1, 2]. Subsequently, p is reindexed using p.reindex([1, 2, 3]), creating a new Series p1. The output displays both p and p1.