Write a Pandas program to convert given series into a dataframe with its index as another column on the dataframe
import numpy as np import pandas as pd char_list = list('ABCDEFGHIJKLMNOP') num_arra = np.arange(8) num_dict = dict(zip(char_list, num_arra)) num_ser = pd.Series(num_dict) df = num_ser.to_frame().reset_index() print(df.head())
Sample Output:
index 0 0 A 0 1 B 1 2 C 2 3 D 3 4 E 4
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer