Q. What is the output of the following code?


import pandas as pd

import numpy as np

x = pd.DataFrame({"var1": np.arange (1,20,2)}, index = [9,8,7,6,10, 1, 2, 3, 4, 5])

x1 = x.iloc [4:7]

x2 = x.head (2)

x3= x.tail (4)

print("x1:")

x3= x.tail (4)

print("x1:")

print (x1)

print("x2:")

print (x2)

print("x3:")

print (x3)


Answer :-

x1:
x1:
    var1
10     9
1     11
2     13
x2:
   var1
9     1
8     3
x3:
   var1
2    13
3    15
4    17
5    19
>>>

Post a Comment

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

Previous Post Next Post