Q. Why does the following code cause error?


s1 = pd. Series (range 1, 15, 5), index = list ('ababa')

print (s1 ['ab'])


Answer :

The above code causes an error because the syntax used to define the s1 series object is incorrect. Specifically, the parentheses used to define the range object within the pd.Series() function call are not correctly placed.  you should place the parentheses around the entire range() function call, like this:

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post