Computer Science, asked by prachij077, 8 months ago

Find the Error :

data = np.array( [‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’] )

s = pd.Series(data, index =[100,101, 102, 103, 104, 105])

print( s [102, 103, 104] )

Can you correct the error ?

Answers

Answered by Legend12R
4

Answer:

pd.Series(np.random.randn(5), index=['a', 'b', 'c', 'd', 'e']) In [4]: s Out[4]: a 0.469112 b -0.282863 c -1.509059 d ...

s = pd.Series(data, index =[100,101, 102, 103, 104, 105])

print( s [102, 103, 104] )

#+#+#+#+#+#+#+104...........

Explanation:

Hope you find this helpful........

Answered by iamzain
2

Answer:

Error - KeyError: (102, 103, 104)

Correction 1 - print(s[2:5])

Correction 2 - print(s.loc[102:104])

Explanation:

Error - 3 index given at same time

Similar questions