Write a Pandas program to convert given series into a dataframe with its index as another column on the dataframe
- برمجة بايثون
- 2021-09-10
- mhanasmh00489829403
الأجوبة
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
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال