Informatics Practices
What will be the output of the following code ?
import pandas as pd
myser = pd.Series([0, 0, 0])
print(myser)
- 0 0
0 0
0 0 - 0 1
0 1
0 2 - 0 0
1 0
2 0 - 0 0
1 1
2 2
Answer
0 0
1 0
2 0
Reason — The code creates a pandas Series object myser with three elements [0, 0, 0], and when we print the Series, it displays the index along with the corresponding values. Since the Series is created with default indexes (0, 1, 2), the output shows the index values (0, 1, 2) along with the corresponding values (0, 0, 0).
Related Questions
Which of the following statement is wrong ?
- We can't change the index of the series
- We can easily convert the list, tuple, and dictionary into a series
- A series represents a single column in memory
- We can create empty series.
What type of error is returned by the following statement ?
import pandas as pa pa.Series([1, 2, 3, 4], index = ['a', 'b', 'c'])- Value Error
- Syntax Error
- Name Error
- Logical Error
To display last five rows of a series object 'S', you may write :
- S.Head()
- S.Tail(5)
- S.Head(5)
- S.tail()
Missing data in Pandas object is represented through :
- Null
- None
- Missing
- NaN