CBSE Class 12 Informatics Practices Question 117 of 167

Python Pandas — I — Question 7

Back to all questions
7
Question

Question 6(b)

Find the error in following code fragment :

S = pd.Series(2, 3, 4, 5, index = range(4)) 
Answer

In the above code fragment, the data values should be enclosed in square brackets [] to form a list.

The corrected code is:

S = pd.Series([2, 3, 4, 5], index = range(4))