Q. If Ser is a Series type object having 30 values, then how are statements (a), (b) and (c), (d) similar and different?


(a) print(Ser.head( ))

(b) print(Ser.head( 8 ))

(c) print(Ser.tail())

(d) print(Ser.tail(11))


Answer =

(a) Prints first 5 elements of series

(b) Prints first 8 elements of series

(c) Print  last 5 elements of series

(d) Prints last 11 elements of series


(a), (b), (c), and (d) are the statements used to display the elements of the Series object Ser, But they differ in the way they display the elements..


(a) Ser.head() will print the first 5 elements of the Series Ser. The head() function is used to get the top n elements of the Series, where n is 5 by default if not specified.


(b) Ser.head(8) will print the first 8 elements of the Series Ser. The parameter n is set to 8 to get the top 8 elements of the Series.


(c) Ser.tail() will print the last 5 elements of the Series Ser. tail() function is used to get the last n elements of the Series, where n is 5 by default if not specified.


(d) Ser.tail(11) will print the last 11 elements of the Series Ser. The parameter n is set to 11 to get the last 11 elements of the Series.


(a) and (c) are similar in that they both display the top and bottom 5 elements of the Series, respectively, while (b) and (d) are similar in that they both display the top and bottom n elements of the Series, respectively, where n is specified as a parameter.


5 Comments

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

  1. Why is it printing 5 elements when the bracket is empty?

    ReplyDelete
    Replies
    1. Because the default vaule of head and tail function is 5.

      Delete
    2. (a), (b), (c), and (d) are the statements used to display the elements of the Series object Ser, But they differ in the way they display the elements..

      (a) Ser.head() will print the first 5 elements of the Series Ser. The head() function is used to get the top n elements of the Series, where n is 5 by default if not specified.

      (b) Ser.head(8) will print the first 8 elements of the Series Ser. The parameter n is set to 8 to get the top 8 elements of the Series.

      (c) Ser.tail() will print the last 5 elements of the Series Ser. tail() function is used to get the last n elements of the Series, where n is 5 by default if not specified.

      (d) Ser.tail(11) will print the last 11 elements of the Series Ser. The parameter n is set to 11 to get the last 11 elements of the Series.

      (a) and (c) are similar in that they both display the top and bottom 5 elements of the Series, respectively, while (b) and (d) are similar in that they both display the top and bottom n elements of the Series, respectively, where n is specified as a parameter.

      Delete
  2. Because the default value of head and tail function is 5

    ReplyDelete

Post a Comment

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

Previous Post Next Post