Pandas

Pandas (3)

알 수 없는 사용자 2022. 7. 20. 00:40
728x90

How to convert the index of a series into a column of a dataframe?

# Input
mylist = list('abcedfghijklmnopqrstuvwxyz')
myarr = np.arange(26)
mydict = dict(zip(mylist, myarr))
ser = pd.Series(mydict)

# Solution
df = ser.to_frame().reset_index()