Informatics Practices
Carefully observe the following code:
import pandas as pd
list_of_dict = [
{ 'Name' : 'Sourab' , 'Age' : 35, 'Marks' : 91},
{ 'Name' : 'Rohan', 'Age' : 31, 'Marks' : 87} ,
{ 'Name' : ' Shalini', 'Age' : 33, 'Marks' : 78},
{ 'Name' : ' Divya' , 'Age' : 23, 'Marks' : 93}
]
df = pd. DataFrame (list_of_dict)
print (df)
Answer the following:
(i) List the index of the DataFrame df.
(ii) List the column names of DataFrame df.
Python Pandas
1 Like
Answer
(i) The index of the DataFrame df will be the default integer index range starting from 0 to the number of rows minus one. In this case, since df is created from a list of dictionaries, the index will be [0, 1, 2, 3].
(ii) The column names of DataFrame df is 'Name', 'Age', 'Marks'.
Answered By
1 Like
Related Questions
How do computer networks reduce hardware costs of an organization? Explain with the help of an example.
Differentiate between Static and Dynamic web pages.
What is the purpose of DROP TABLE command in MySql ? How is it different from DELETE command ?
Write Python code to create the following Series Stock (using list):
1 PEN
2 PENCIL
3 ERASER