Q:

Write a Pandas program to convert given series into a dataframe with its index as another column on the dataframe

0

Write a Pandas program to convert given series into a dataframe with its index as another column on the dataframe

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now