Articles → Pandas → Set_Index Function In Pandas

Set_Index Function In Pandas






Purpose





Example


import numpy as np
import pandas as pd


df = pd.DataFrame(np.random.randn(4,3),['A','B','C','D',],['W','X','Y'])

print(df.index)

df.set_index(df["X"], inplace=True)

print(df.index)



Output


Picture showing the output of set_index function in pandas
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Thursday, April 25, 2019

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250