Recall & Review
beginner
What does the
shape attribute of a pandas DataFrame tell you?The
shape attribute shows the number of rows and columns in the DataFrame as a tuple: (rows, columns).Click to reveal answer
beginner
How can you get the number of rows in a pandas DataFrame using
shape?Use
df.shape[0] to get the number of rows in the DataFrame df.Click to reveal answer
beginner
How do you find the number of columns in a pandas DataFrame using
shape?Use
df.shape[1] to get the number of columns in the DataFrame df.Click to reveal answer
beginner
What type of value does
shape return in pandas?shape returns a tuple of two integers representing (number of rows, number of columns).Click to reveal answer
beginner
If a DataFrame
df has df.shape == (100, 5), what does it mean?It means
df has 100 rows and 5 columns.Click to reveal answer
What does
df.shape return for a pandas DataFrame?✗ Incorrect
df.shape returns a tuple showing the number of rows and columns.How do you get the number of columns from
df.shape?✗ Incorrect
The second element of the tuple (
df.shape[1]) is the number of columns.If
df.shape is (50, 10), how many rows does df have?✗ Incorrect
The first number in the tuple is the number of rows.
Which of these is NOT true about
df.shape?✗ Incorrect
df.shape does not return data types; it returns the dimensions.What Python type is returned by
df.shape?✗ Incorrect
df.shape returns a tuple with two integers.Explain what the
shape attribute of a pandas DataFrame represents and how to use it to find the number of rows and columns.Think of shape as the size of a table: rows first, then columns.
You got /3 concepts.
Describe a real-life example where knowing the shape of your data helps in data analysis.
Imagine you just opened a spreadsheet and want to know how big it is.
You got /3 concepts.