Informatics Practices

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]

Python Pandas

3 Likes

Answer

import pandas as pd
data = [
    ['S101', 'Amy', 70],
    ['S102', 'Bandhi', 69],
    ['S104', 'Cathy', 75],
    ['S105', 'Gundaho', 82]
]
columns = ['ID', 'Name', 'Score']
df = pd.DataFrame(data, columns=columns)
print(df)
Output
     ID     Name  Score
0  S101      Amy     70
1  S102   Bandhi     69
2  S104    Cathy     75
3  S105  Gundaho     82

Answered By

1 Like


Related Questions