0 votes
10 views
ago in Computer Science by (8.5k points)
Sneha is writing a Python program to create a DataFrame using a list of dictionaries. However, her code contains some mistakes. Identify the errors,

rewrite the correct code, and underline the corrections made.

import Pandas as pd

D1 = {'Name': 'Rakshit', 'Age': 25}

D2 = {'Name': 'Paul', 'Age': 30}

D3 = {'Name': 'Ayesha", 'Age': 28}

data = [D1,D2,D3)

df = pd.Dataframe(data)

print(df)

1 Answer

0 votes
ago by (56.5k points)
 
Best answer
import pandas as pd

D1 = {'Name': 'Rakshit', 'Age': 25}

D2 = {'Name': 'Paul', 'Age': 30}

D3 = {'Name': 'Ayesha', 'Age': 28}

data = [D1, D2, D3]

df = pd.DataFrame(data)

print(df)

Changes Made :

i. Changed Pandas to pandas.

ii. Corrected mismatched string quotation marks

iii. Corrected the closing parenthesis in the list data.

iv. Changed Dataframe to DataFrame.
...