Advertisements
Advertisements
प्रश्न
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)
कोड लेखन
उत्तर
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:
- Changed Pandas to pandas.
- Corrected mismatched string quotation marks.
- Corrected the closing parenthesis in the list data.
- Changed Dataframe to DataFrame.
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?