Close
Close

Write the output for the following code?

   Karnima53

import pandas as pd
s=pd.series({"a":97,"b":98,"c":99,"d":100})
print(s.loc['b':'c'])
print(s.iloc[2:3])

  • Hey, The 'S' of pd.Series should be capital. The 3rd and 4rth lines are slicing Pandas Series. s.loc is extracting those items having index name 'b' and 'c'. It includes the last given item. s.iloc is extracting items based on index position. It does not include the last item.
    - Aqsa Mustafa

Answers

  •   

    Hey, The 'S' of pd.Series should be capital. The 3rd and 4rth lines are slicing Pandas Series. s.loc is extracting those items having index name 'b' and 'c'. It includes the last given item. s.iloc is extracting items based on index position. It does not include the last item.
    - Aqsa Mustafa



Ask Yours
Post Yours
Write your answer