Write a Python program to convert the index of a series into a column of a dataframe


Topic: Write a Python program to convert the index of a series into a column of a dataframe

Solution

import pandas as pd
import numpy as np
mylist = list('abcedfghijklmnopqrstuvwxyz')
myarr = np.arange(26)
mydict = dict(zip(mylist, myarr))
ser = pd.Series(mydict)
df = ser.to_frame().reset_index()
print(df.head())



List all Python Programs