0
0
Pandasdata~5 mins

head() and tail() for previewing in Pandas - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the head() function do in pandas?
The head() function shows the first few rows of a DataFrame or Series, helping you quickly see the start of your data.
Click to reveal answer
beginner
How do you use tail() in pandas and what does it show?
tail() shows the last few rows of a DataFrame or Series, letting you quickly check the end of your data.
Click to reveal answer
beginner
By default, how many rows do head() and tail() show?
Both head() and tail() show 5 rows by default if no number is given.
Click to reveal answer
beginner
How can you see the first 10 rows of a DataFrame named df?
Use df.head(10) to see the first 10 rows.
Click to reveal answer
beginner
Why is it useful to preview data with head() and tail()?
Previewing helps you quickly understand the data structure, check for missing values, and confirm data loading without looking at the whole dataset.
Click to reveal answer
What does df.head() return by default?
AFirst 5 rows of df
BLast 5 rows of df
CFirst 10 rows of df
DAll rows of df
How do you get the last 3 rows of a DataFrame df?
Adf.end(3)
Bdf.head(3)
Cdf.last(3)
Ddf.tail(3)
If you want to preview the start and end of your data, which two functions do you use?
Astart() and end()
Bhead() and tail()
Cfirst() and last()
Dtop() and bottom()
What type of object do head() and tail() return?
AA plot
BA list of values
CA new DataFrame or Series with selected rows
DA summary statistic
Can you specify how many rows to preview with head() and tail()?
AYes, by passing a number as an argument
BNo, they always show 5 rows
COnly <code>head()</code> allows this
DOnly <code>tail()</code> allows this
Explain how and why you would use head() and tail() when starting to analyze a new dataset.
Think about what you want to learn quickly from the data.
You got /4 concepts.
    Describe the default behavior of head() and tail() and how to change the number of rows they show.
    Remember the default and how to customize.
    You got /3 concepts.