What does df.head() return by default in pandas?
Correct answer
C. The first five rows of the DataFrame
15 views
C. The first five rows of the DataFrame
15 views
head() returns the first five rows, and passing an integer such as head(10) changes the count; tail() mirrors it from the bottom of the frame. It is a preview method for inspection, so it returns a new DataFrame rather than modifying the original. For a statistical summary of numeric columns you need describe(), and for dtypes you use the dtypes attribute.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is C? Ask here and get an explanation.