Pandas

Pandas (3)

Jun's N 2022. 7. 20. 00:40

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()
728x90