0
0
Pandasdata~5 mins

shape for dimensions in Pandas - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AA tuple with (rows, columns)
BA list of column names
CThe total number of cells
DThe data types of columns
How do you get the number of columns from df.shape?
A<code>df.shape[0]</code>
B<code>df.shape[1]</code>
C<code>len(df.shape)</code>
D<code>df.columns</code>
If df.shape is (50, 10), how many rows does df have?
A50
B500
C60
D10
Which of these is NOT true about df.shape?
AIt returns a tuple
BIt shows the DataFrame size
CIt returns the data types of columns
DIt has two elements
What Python type is returned by df.shape?
AInteger
BList
CDictionary
DTuple
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.