KnowledgeBoat Logo
|

Informatics Practices

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)

Python Pandas

1 Like

Answer

0    Rahul
1     Aman
2    Karan
dtype: object
1     Aman
2    Karan
3      NaN
dtype: object

Working

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.

Answered By

2 Likes


Related Questions