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
Click to Enlarge