Q. What will the following code do ?


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)

Answer :-

The given code is creating a DataFrame x from the given data and indexes. (First line of code)
Second line of code is creating a DataFrame x1 which will store 4, 5, 6 rows of x.
Third line of code is creating a DataFrame x2 which will store first 2 rows of x..
Fourth line of code is creating a DataFrame x3 which will store last 4 rows of x.

Post a Comment

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

Previous Post Next Post