Informatics Practices
Find the error in following code fragment :
S = pd.Series(2, 3, 4, 5, index = range(4))
Python Pandas
1 Like
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))
Answered By
1 Like
Related Questions
Write a Python program to create a series object, country using a list that stores the capital of each country.
Note. Assume four countries to be used as index of the series object are India, UK, Denmark and Thailand having their capitals as New Delhi, London, Copenhagen and Bangkok respectively.
Find the error in following code fragment :
S2 = pd.Series([101, 102, 102, 104]) print(S2.index) S2.index = [0, 1, 2, 3, 4, 5] S2[5] = 220 print(S2)Find the error in following code fragment
S1 = pd.Series(1, 2, 3, 4, index = range(7))Find the error in following code fragment :
S2 = pd.Series([1, 2, 3, 4], index = range(4))