[Solved] Write a Python code to create a dataframe with appropriate headings from the list given below :

   RSS

1
Topic starter

Write a Python code to create a dataframe with appropriate headings from the list given below :

[ ‘S101’,’Amy’,70],[‘S102’,’Bandhi’,69],[‘S104’,’Cathy’,75],[‘S105’,’Gundaho’,82]

1 Answer
1
Topic starter

Code:

import pandas as pd


data = ['S101','Amy',70],['S102','Bandhi',69],['S104','Cathy',75],['S105','Gundaho',82]


df = pd.DataFrame(data, columns = ['ID', 'Name', 'Marks'])


print(df)

Output:

     ID     Name  Marks
0  S101      Amy     70
1  S102   Bandhi     69
2  S104    Cathy     75
3  S105  Gundaho     82